猎豆优选

LDSuperBrandCollectionCell.m 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // LDSuperBrandCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDSuperBrandCollectionCell.h"
  9. @interface LDSuperBrandCollectionCell ()
  10. @property (nonatomic, strong) UIImageView *bgImgView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UILabel *desLabel;
  13. @end
  14. @implementation LDSuperBrandCollectionCell
  15. - (instancetype)initWithFrame:(CGRect)frame
  16. {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. [self initSubViews];
  20. }
  21. return self;
  22. }
  23. - (void)initSubViews {
  24. [self.contentView addSubview:self.bgImgView];
  25. [self.contentView addSubview:self.titleLabel];
  26. [self.contentView addSubview:self.desLabel];
  27. [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
  29. }];
  30. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.right.left.mas_equalTo(0);
  32. make.top.mas_equalTo(62);
  33. }];
  34. [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.right.mas_equalTo(0);
  36. make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(3);
  37. }];
  38. }
  39. - (void)setModel:(LDSuperBrandModel *)model {
  40. [self.bgImgView sd_setFadeImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil options:0 progress:nil completed:nil];
  41. self.titleLabel.text = model.name;
  42. self.desLabel.text = model.note;
  43. }
  44. - (UIImageView *)bgImgView {
  45. if (!_bgImgView) {
  46. _bgImgView = [[UIImageView alloc] init];
  47. }
  48. return _bgImgView;
  49. }
  50. - (UILabel *)titleLabel {
  51. if (!_titleLabel) {
  52. _titleLabel = [[UILabel alloc] init];
  53. _titleLabel.textAlignment = NSTextAlignmentCenter;
  54. _titleLabel.font = [UIFont systemFontOfSize:12];
  55. _titleLabel.textColor = [UIColor YHColorWithHex:0x4A4A4A];
  56. }
  57. return _titleLabel;
  58. }
  59. - (UILabel *)desLabel {
  60. if (!_desLabel) {
  61. _desLabel = [[UILabel alloc] init];
  62. _desLabel.font = [UIFont systemFontOfSize:8];
  63. _desLabel.textColor = [UIColor YHColorWithHex:0x9B9B9B];
  64. _desLabel.textAlignment = NSTextAlignmentCenter;
  65. }
  66. return _desLabel;
  67. }
  68. @end