猎豆优选

LDClassifyRightCollectionViewCell.m 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // LDClassifyRightCollectionViewCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/4/28.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDClassifyRightCollectionViewCell.h"
  9. @implementation LDClassifyRightCollectionViewCell
  10. {
  11. UILabel *_titleLabel;
  12. UIImageView *_imgView;
  13. }
  14. - (instancetype)initWithFrame:(CGRect)frame{
  15. if (self = [super initWithFrame:frame]) {
  16. [self setupUI];
  17. }
  18. return self;
  19. }
  20. - (void)setupUI{
  21. _titleLabel = [[UILabel alloc]init];
  22. _titleLabel.textAlignment = NSTextAlignmentCenter;
  23. _titleLabel.textColor = [UIColor YHColorWithHex:0x666666];
  24. _titleLabel.font = [UIFont systemFontOfSize:12];
  25. [self.contentView addSubview:_titleLabel];
  26. _imgView = [[UIImageView alloc] init];
  27. _imgView.contentMode = UIViewContentModeScaleAspectFill;
  28. [self.contentView addSubview:_imgView];
  29. [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.mas_equalTo(FITSIZE(22));
  31. make.centerX.mas_equalTo(self.mas_centerX);
  32. make.width.height.mas_equalTo(FITSIZE(50));
  33. }];
  34. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.mas_equalTo(_imgView.mas_bottom).mas_offset(FITSIZE(5));
  36. make.left.right.mas_equalTo(0);
  37. make.height.mas_equalTo(FITSIZE(20));
  38. }];
  39. }
  40. - (void)setModel:(LDSecondCategoryModel *)model {
  41. _titleLabel.text = model.name;
  42. [_imgView yy_setImageWithURL:[NSURL URLWithString:model.img] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
  43. }
  44. @end