123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // ASProductItemView.m
- // Asteria
- //
- // Created by iOS on 2023/5/17.
- //
- #import "ASProductItemView.h"
- @interface ASProductItemView ()
- @property (nonatomic, strong) UIImageView *imgV;
- @property (nonatomic, strong) UILabel *titleLb;
- @property (nonatomic, strong) UILabel *nowPriceLb;
- @property (nonatomic, strong) UILabel *oldPriceLb;
- @property (nonatomic,strong) UILabel *hotLb;
- @property (nonatomic,strong) UIStackView *lbStackV;
- @property (nonatomic,strong) UIButton *addCartBt;
- //@property (nonatomic, strong)UIStackView *priceStackV;
- //@property (nonatomic, strong) UIView* hotV;
- @end
- @implementation ASProductItemView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self configSubV];
- self.clipsToBounds = true;
- }
- return self;
- }
- - (void) configSubV {
- self.layer.cornerRadius = 8;
- self.layer.masksToBounds = true;
- self.backgroundColor = _F5F5F5;
-
- [self addSubview:self.imgV];
- [self addSubview:self.titleLb];
- [self addSubview:self.hotLb];
- [self addSubview: self.nowPriceLb];
- [self addSubview: self.oldPriceLb];
-
-
- }
- - (UIImageView *)imgV {
- if (!_imgV) {
- UIImageView *v = [[UIImageView alloc] init];
- v.contentMode = UIViewContentModeScaleToFill;
- _imgV = v;
- }
- return _imgV;
- }
- - (UILabel *)titleLb {
- if (!_titleLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = [UIColor blackColor];
- lb.textAlignment = NSTextAlignmentLeft;
- lb.numberOfLines = 2;
- _titleLb = lb;
- }
- return _titleLb;
- }
- - (UILabel *)nowPriceLb {
- if (!_nowPriceLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Bold size:14];
- lb.textColor = [UIColor blackColor];
- lb.textAlignment = NSTextAlignmentLeft;
- _nowPriceLb = lb;
- }
- return _nowPriceLb;
- }
- - (UILabel *)oldPriceLb {
- if (!_oldPriceLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = Col_999;
- lb.textAlignment = NSTextAlignmentLeft;
- _oldPriceLb = lb;
- }
- return _oldPriceLb;
- }
- - (UILabel *)hotLb {
- if (!_hotLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = Col_666;
- lb.textAlignment = NSTextAlignmentLeft;
- _hotLb = lb;
- }
- return _hotLb;
- }
- -(UIButton *)addCartBt {
- if (!_addCartBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- [bt setImage:[UIImage imageNamed:@"list_addbag"] forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(addCartBtAction) forControlEvents:UIControlEventTouchUpInside];
- _addCartBt = bt;
- }
- return _addCartBt;
- }
- - (void)addCartBtAction {
- // if (self.addCartBlock) {
- // self.addCartBlock(self.model);
- // }
- }
- @end
|