ASProductItemView.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // ASProductItemView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/5/17.
  6. //
  7. #import "ASProductItemView.h"
  8. @interface ASProductItemView ()
  9. @property (nonatomic, strong) UIImageView *imgV;
  10. @property (nonatomic, strong) UILabel *titleLb;
  11. @property (nonatomic, strong) UILabel *nowPriceLb;
  12. @property (nonatomic, strong) UILabel *oldPriceLb;
  13. @property (nonatomic,strong) UILabel *hotLb;
  14. @property (nonatomic,strong) UIStackView *lbStackV;
  15. @property (nonatomic,strong) UIButton *addCartBt;
  16. //@property (nonatomic, strong)UIStackView *priceStackV;
  17. //@property (nonatomic, strong) UIView* hotV;
  18. @end
  19. @implementation ASProductItemView
  20. - (instancetype)initWithFrame:(CGRect)frame {
  21. self = [super initWithFrame:frame];
  22. if (self) {
  23. [self configSubV];
  24. self.clipsToBounds = true;
  25. }
  26. return self;
  27. }
  28. - (void) configSubV {
  29. self.layer.cornerRadius = 8;
  30. self.layer.masksToBounds = true;
  31. self.backgroundColor = _F5F5F5;
  32. [self addSubview:self.imgV];
  33. [self addSubview:self.titleLb];
  34. [self addSubview:self.hotLb];
  35. [self addSubview: self.nowPriceLb];
  36. [self addSubview: self.oldPriceLb];
  37. }
  38. - (UIImageView *)imgV {
  39. if (!_imgV) {
  40. UIImageView *v = [[UIImageView alloc] init];
  41. v.contentMode = UIViewContentModeScaleToFill;
  42. _imgV = v;
  43. }
  44. return _imgV;
  45. }
  46. - (UILabel *)titleLb {
  47. if (!_titleLb) {
  48. UILabel *lb = [[UILabel alloc] init];
  49. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  50. lb.textColor = [UIColor blackColor];
  51. lb.textAlignment = NSTextAlignmentLeft;
  52. lb.numberOfLines = 2;
  53. _titleLb = lb;
  54. }
  55. return _titleLb;
  56. }
  57. - (UILabel *)nowPriceLb {
  58. if (!_nowPriceLb) {
  59. UILabel *lb = [[UILabel alloc] init];
  60. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  61. lb.textColor = [UIColor blackColor];
  62. lb.textAlignment = NSTextAlignmentLeft;
  63. _nowPriceLb = lb;
  64. }
  65. return _nowPriceLb;
  66. }
  67. - (UILabel *)oldPriceLb {
  68. if (!_oldPriceLb) {
  69. UILabel *lb = [[UILabel alloc] init];
  70. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  71. lb.textColor = Col_999;
  72. lb.textAlignment = NSTextAlignmentLeft;
  73. _oldPriceLb = lb;
  74. }
  75. return _oldPriceLb;
  76. }
  77. - (UILabel *)hotLb {
  78. if (!_hotLb) {
  79. UILabel *lb = [[UILabel alloc] init];
  80. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  81. lb.textColor = Col_666;
  82. lb.textAlignment = NSTextAlignmentLeft;
  83. _hotLb = lb;
  84. }
  85. return _hotLb;
  86. }
  87. -(UIButton *)addCartBt {
  88. if (!_addCartBt) {
  89. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  90. [bt setImage:[UIImage imageNamed:@"list_addbag"] forState:UIControlStateNormal];
  91. [bt addTarget:self action:@selector(addCartBtAction) forControlEvents:UIControlEventTouchUpInside];
  92. _addCartBt = bt;
  93. }
  94. return _addCartBt;
  95. }
  96. - (void)addCartBtAction {
  97. // if (self.addCartBlock) {
  98. // self.addCartBlock(self.model);
  99. // }
  100. }
  101. @end