XYPersonalContentNormalItemCollectionViewCell.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // XYPersonalContentNormalItemCollectionViewCell.m
  3. // TianYou
  4. //
  5. // Created by 翟玉磊 on 2021/7/21.
  6. //
  7. #import "XYPersonalContentNormalItemCollectionViewCell.h"
  8. #import "XYPersonalCenterListModel.h"
  9. @interface XYPersonalContentNormalItemCollectionViewCell ()
  10. @property (nonatomic, strong) UIImageView *contentImageView;
  11. @property (nonatomic, strong) UILabel *contentLabel;
  12. @end
  13. @implementation XYPersonalContentNormalItemCollectionViewCell
  14. - (void)configureModel:(XYPersonalCenterListModel *)model {
  15. self.contentImageView.image = ImageNamed(model.iconName);
  16. self.contentLabel.text = model.title;
  17. }
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. if (self = [super initWithFrame:frame]) {
  20. [self setupUI];
  21. }
  22. return self;
  23. }
  24. - (void)setupUI {
  25. [self.contentView addSubview:self.contentImageView];
  26. [self.contentView addSubview:self.contentLabel];
  27. [self.contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.centerX.equalTo(self.contentView);
  29. make.top.equalTo(self.contentView).offset(11.0f);
  30. make.width.height.equalTo(@24.0f);
  31. }];
  32. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.right.equalTo(self.contentView);
  34. make.top.equalTo(self.contentImageView.mas_bottom).offset(4.0f);
  35. make.height.equalTo(@17.0f);
  36. }];
  37. }
  38. #pragma mark — Getter
  39. - (UIImageView *)contentImageView {
  40. if (!_contentImageView) {
  41. _contentImageView = [UIImageView new];
  42. }
  43. return _contentImageView;
  44. }
  45. - (UILabel *)contentLabel {
  46. if (!_contentLabel) {
  47. _contentLabel = [UILabel createLabelTextColor:Color_Nakaguro fount:Font(12)];
  48. _contentLabel.textAlignment = NSTextAlignmentCenter;
  49. }
  50. return _contentLabel;
  51. }
  52. @end