Sin descripción

LFWFindMiddleCollectionViewCell.m 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // LFWFindMiddleCollectionViewCell.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LFWFindMiddleCollectionViewCell.h"
  9. @implementation LFWFindMiddleCollectionViewCell
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. [self initSubviews];
  14. }
  15. return self;
  16. }
  17. - (void)initSubviews {
  18. [self.contentView.layer addSublayer:self.pictureLayer];
  19. [self.contentView addSubview:self.nameLabel];
  20. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.centerX.equalTo(self.contentView);
  22. make.top.equalTo(self.contentView).offset(FITSIZE((48+3)));
  23. }];
  24. }
  25. - (void)setModel:(LFWFindChannelModel *)model {
  26. _model = model;
  27. [self.pictureLayer yy_setImageWithURL:[NSURL URLWithString:model.icon] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
  28. self.nameLabel.text = model.name;
  29. }
  30. #pragma mark - lazy {
  31. - (CALayer *)pictureLayer {
  32. if (!_pictureLayer) {
  33. _pictureLayer = [CALayer layer];
  34. _pictureLayer.backgroundColor = [UIColor clearColor].CGColor;
  35. _pictureLayer.frame = CGRectMake(kScreenWidth/8-48/2, 0, FITSIZE(48), FITSIZE(48));
  36. }
  37. return _pictureLayer;
  38. }
  39. - (UILabel *)nameLabel {
  40. if (!_nameLabel) {
  41. _nameLabel = [[UILabel alloc] init];
  42. _nameLabel.textColor = [UIColor YHColorWithHex:0x666666];
  43. _nameLabel.font = [UIFont systemFontOfSize:FITSIZE(12)];
  44. _nameLabel.textAlignment = NSTextAlignmentCenter;
  45. }
  46. return _nameLabel;
  47. }
  48. @end