ASHomeNewInProductItemView.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // ASHomeNewInProductItemView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/9.
  6. //
  7. #import "ASHomeNewInProductItemView.h"
  8. @implementation ASHomeNewInProductItemView
  9. - (void)setModel:(ASProductBaseModel *)model {
  10. [super setModel:model];
  11. self.nowPriceLb.hidden = true;
  12. self.oldPriceLb.hidden = true;
  13. self.priceLb.text = model.nowPrice;
  14. }
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. [self loadSubV];
  19. }
  20. return self;
  21. }
  22. - (void)loadSubV {
  23. [self.addCartBt setImage:[UIImage imageNamed:@"home_newin_addCart"] forState:UIControlStateNormal];
  24. [self addSubview:self.priceBgV];
  25. [self addSubview:self.priceLb];
  26. self.oldPriceLb.hidden = true;
  27. self.nowPriceLb.hidden = true;
  28. self.hotLb.hidden = true;
  29. [self.priceBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.leading.equalTo(self.titleLb);
  31. make.height.equalTo(@16);
  32. make.bottom.equalTo(self.mas_bottom).offset(-20);
  33. make.top.greaterThanOrEqualTo(self.titleLb.mas_bottom).offset(22);
  34. }];
  35. [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.height.equalTo(@29);
  37. make.leading.equalTo(self.priceBgV).offset(25);
  38. make.centerX.equalTo(self.priceBgV);
  39. make.bottom.equalTo(self.priceBgV.mas_bottom).offset(-4.5);
  40. }];
  41. [self.addCartBt mas_remakeConstraints:^(MASConstraintMaker *make) {
  42. make.bottom.trailing.equalTo(self).offset(-20);
  43. make.width.height.equalTo(@36);
  44. }];
  45. }
  46. - (UIImageView *)priceBgV {
  47. if (!_priceBgV) {
  48. UIImageView *imgV = [[UIImageView alloc] init];
  49. imgV.image = [UIImage imageNamed:@"home_newin_priceBg"];
  50. imgV.contentMode = UIViewContentModeScaleToFill;
  51. _priceBgV = imgV;
  52. }
  53. return _priceBgV;
  54. }
  55. - (UILabel *)priceLb {
  56. if (!_priceLb) {
  57. UILabel *lb = [[UILabel alloc] init];
  58. lb.font = [UIFont fontWithName:Rob_Bold size:24];
  59. lb.textColor = [UIColor blackColor];
  60. lb.textAlignment = NSTextAlignmentCenter;
  61. _priceLb = lb;
  62. }
  63. return _priceLb;
  64. }
  65. @end