RoomFaceCell.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // RoomFaceCell.m
  3. // UniversalApp
  4. //
  5. // Created by bogokj on 2019/8/27.
  6. // Copyright © 2019 voidcat. All rights reserved.
  7. //
  8. #import "RoomFaceCell.h"
  9. #import <FLAnimatedImage/FLAnimatedImage.h>
  10. #import "RoomFaceModel.h"
  11. @interface RoomFaceCell ()
  12. @property(nonatomic, strong) FLAnimatedImageView *imageView;
  13. @property(nonatomic, strong) UILabel *titleLabel;
  14. @end
  15. @implementation RoomFaceCell
  16. - (instancetype)initWithFrame:(CGRect)frame{
  17. if (self = [super initWithFrame:frame]) {
  18. [self.contentView addSubview:self.imageView];
  19. [self.contentView addSubview:self.titleLabel];
  20. }
  21. return self;
  22. }
  23. - (void)setModel:(RoomFaceModel *)model{
  24. _model = model;
  25. [self.imageView setImageURL:[NSURL URLWithString:model.img]];
  26. [self.titleLabel setText:model.name];
  27. }
  28. - (FLAnimatedImageView *)imageView{
  29. if (!_imageView) {
  30. // FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"]]];
  31. _imageView = [[FLAnimatedImageView alloc] init];
  32. // imageView.animatedImage = image;
  33. _imageView.frame = CGRectMake(self.width / 4, 15, self.width / 2, self.width / 2);
  34. }
  35. return _imageView;
  36. }
  37. - (UILabel *)titleLabel{
  38. if (!_titleLabel) {
  39. _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.imageView.bottom + 5, self.width, 15)];
  40. _titleLabel.textColor = [UIColor qmui_colorWithHexString:@"#CCCCCC"];
  41. _titleLabel.font = [UIFont systemFontOfSize:12];
  42. _titleLabel.textAlignment = NSTextAlignmentCenter;
  43. }
  44. return _titleLabel;
  45. }
  46. @end