ASHomeLookingCollCell.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // ASHomeLookingCollCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/10.
  6. //
  7. #import "ASHomeLookingCollCell.h"
  8. @interface ASHomeLookingCollCell ()
  9. @property (nonatomic, strong) UIImageView *imgV;
  10. @property (nonatomic, strong) UILabel *titleLb;
  11. @property (nonatomic, strong) ASHomeCategoryModel *model;
  12. @end
  13. @implementation ASHomeLookingCollCell
  14. - (void)setData:(ASHomeCategoryModel *)m {
  15. self.model = m;
  16. [self.imgV sd_setImageWithURL:[NSURL URLWithString:m.imgUrl] placeholderImage:[UIImage imageNamed:@"product_defualtImg"]];
  17. self.titleLb.text = m.title;
  18. }
  19. - (instancetype)initWithFrame:(CGRect)frame {
  20. self = [super initWithFrame:frame];
  21. if (self) {
  22. [self loadVs];
  23. }
  24. return self;
  25. }
  26. - (void)loadVs {
  27. [self.contentView addSubview:self.imgV];
  28. [self.contentView addSubview:self.titleLb];
  29. [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.leading.trailing.equalTo(self.contentView);
  31. make.width.equalTo(self.imgV.mas_height);
  32. }];
  33. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.height.equalTo(@18);
  35. make.bottom.leading.trailing.equalTo(self.contentView);
  36. }];
  37. }
  38. - (UIImageView *)imgV {
  39. if (!_imgV) {
  40. UIImageView *v = [UIImageView baseImgV];
  41. v.contentMode = UIViewContentModeScaleAspectFill;
  42. v.layer.cornerRadius = 8;
  43. v.layer.masksToBounds = true;
  44. v.clipsToBounds = true;
  45. _imgV = v;
  46. }
  47. return _imgV;
  48. }
  49. - (UILabel *)titleLb {
  50. if (!_titleLb) {
  51. UILabel *lb = [UILabel baseLb];
  52. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  53. lb.textAlignment = NSTextAlignmentCenter;
  54. lb.textColor = Col_000;
  55. _titleLb = lb;
  56. }
  57. return _titleLb;
  58. }
  59. @end