|
@@ -22,57 +22,46 @@
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
- _backView = [[UIView alloc] init];
|
|
|
- TT_ViewRadius(_backView, 8);
|
|
|
- _backView.backgroundColor = _113632;
|
|
|
- [self.contentView addSubview:_backView];
|
|
|
- [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ [self.contentView addSubview:self.backView];
|
|
|
+
|
|
|
+ [self.backView addSubview:self.titleLab];
|
|
|
+ [self.backView addSubview:self.titleDescLab];
|
|
|
+ [self.backView addSubview:self.rTopBtn];
|
|
|
+
|
|
|
+ [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.mas_equalTo(10);
|
|
|
make.top.mas_equalTo(10);
|
|
|
make.right.mas_equalTo(-10);
|
|
|
-// make.height.mas_equalTo(45);
|
|
|
make.bottom.mas_equalTo(0);
|
|
|
}];
|
|
|
|
|
|
- _titleLab = [UILabel labelCreateWithText:@"COUPON" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_FFF];
|
|
|
- _titleDescLab.adjustsFontSizeToFitWidth = YES;
|
|
|
- [_backView addSubview:_titleLab];
|
|
|
- [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.mas_equalTo(10);
|
|
|
make.top.mas_equalTo(12);
|
|
|
make.height.mas_equalTo(20);
|
|
|
make.width.mas_equalTo(60);
|
|
|
}];
|
|
|
|
|
|
- _titleDescLab = [UILabel labelCreateWithText:@"All wigs 10% off code:wkwig" font:[UIFont fontWithName:Rob_Regular size:12] textColor:Col_FFF];
|
|
|
- _titleDescLab.adjustsFontSizeToFitWidth = YES;
|
|
|
- [_backView addSubview:_titleDescLab];
|
|
|
- [_titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(_titleLab.mas_right).offset(4);
|
|
|
- make.centerY.mas_equalTo(_titleLab);
|
|
|
+ [self.titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(self.titleLab.mas_right).offset(4);
|
|
|
+ make.centerY.mas_equalTo(self.titleLab);
|
|
|
make.right.mas_equalTo(-40);
|
|
|
}];
|
|
|
|
|
|
- _rTopBtn = [[UIButton alloc]init];
|
|
|
-// _rTopBtn.selected = NO;
|
|
|
- [_rTopBtn addTarget:self action:@selector(_couponEvent:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
- [_rTopBtn setImage:[UIImage imageNamed:@"base_add_white"] forState:UIControlStateNormal];
|
|
|
- [_rTopBtn setImage:[UIImage imageNamed:@"base_subtract_white"] forState:UIControlStateSelected];
|
|
|
- [_backView addSubview:_rTopBtn];
|
|
|
- [_rTopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.centerY.equalTo(_titleLab);
|
|
|
+ [self.rTopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(self.titleLab);
|
|
|
make.right.mas_equalTo(0);
|
|
|
make.width.mas_equalTo(40);
|
|
|
make.height.mas_equalTo(30);
|
|
|
}];
|
|
|
|
|
|
- _couponView = [[UIView alloc] init];
|
|
|
- _couponView.backgroundColor = [UIColor clearColor];
|
|
|
- [_backView addSubview:_couponView];
|
|
|
- [_couponView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ [self.backView addSubview:self.couponView];
|
|
|
+ [self.couponView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.bottom.mas_equalTo(0);
|
|
|
make.height.mas_equalTo(1);
|
|
|
- make.top.mas_equalTo(_titleLab.mas_bottom).offset(12);
|
|
|
+ make.top.mas_equalTo(self.titleLab.mas_bottom).offset(12);
|
|
|
make.bottom.mas_equalTo(0);
|
|
|
}];
|
|
|
}
|
|
@@ -102,7 +91,7 @@
|
|
|
for (int i = 0; i < array.count; i++) {
|
|
|
ASGoodsCouponItemView *itemView = [[ASGoodsCouponItemView alloc] initWithFrame:CGRectMake(itemX, itemY, itemWidth, 100)];
|
|
|
itemView.tag = i;
|
|
|
- [_couponView addSubview:itemView];
|
|
|
+ [self.couponView addSubview:itemView];
|
|
|
|
|
|
itemView.userInteractionEnabled = YES;
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_clickAction:)];
|
|
@@ -122,7 +111,7 @@
|
|
|
itemY = itemY + 100 + 10;
|
|
|
}
|
|
|
|
|
|
- [_couponView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.couponView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
make.height.mas_equalTo(itemY);
|
|
|
}];
|
|
|
|
|
@@ -147,10 +136,55 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (UIView *)backView {
|
|
|
+ if (!_backView) {
|
|
|
+ _backView = [[UIView alloc] init];
|
|
|
+ TT_ViewRadius(_backView, 8);
|
|
|
+ _backView.backgroundColor = _113632;
|
|
|
+ }
|
|
|
+ return _backView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleLab {
|
|
|
+ if (!_titleLab) {
|
|
|
+ _titleLab = [UILabel labelCreateWithText:@"COUPON" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_FFF];
|
|
|
+ _titleLab.adjustsFontSizeToFitWidth = YES;
|
|
|
+ }
|
|
|
+ return _titleLab;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleDescLab {
|
|
|
+ if (!_titleDescLab) {
|
|
|
+ _titleDescLab = [UILabel labelCreateWithText:@"All wigs 10% off code:wkwig" font:[UIFont fontWithName:Rob_Regular size:12] textColor:Col_FFF];
|
|
|
+ _titleDescLab.adjustsFontSizeToFitWidth = YES;
|
|
|
+ }
|
|
|
+ return _titleDescLab;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)rTopBtn {
|
|
|
+ if (!_rTopBtn) {
|
|
|
+ _rTopBtn = [[UIButton alloc]init];
|
|
|
+// _rTopBtn.selected = NO;
|
|
|
+ [_rTopBtn addTarget:self action:@selector(_couponEvent:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [_rTopBtn setImage:[UIImage imageNamed:@"base_add_white"] forState:UIControlStateNormal];
|
|
|
+ [_rTopBtn setImage:[UIImage imageNamed:@"base_subtract_white"] forState:UIControlStateSelected];
|
|
|
+ }
|
|
|
+ return _rTopBtn;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)couponView {
|
|
|
+ if (!_couponView) {
|
|
|
+ _couponView = [[UIView alloc] init];
|
|
|
+ _couponView.backgroundColor = [UIColor clearColor];
|
|
|
+ }
|
|
|
+ return _couponView;
|
|
|
+}
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@interface ASGoodsCouponItemView()
|
|
|
|
|
|
+@property (nonatomic, strong) UIImageView *bgImaegView;
|
|
|
@property (nonatomic, strong) UILabel *couponCodeLab;
|
|
|
@property (nonatomic, strong) UILabel *couponPriceLab;
|
|
|
@property (nonatomic, strong) UILabel *couponDescLab;
|
|
@@ -160,26 +194,40 @@
|
|
|
|
|
|
@implementation ASGoodsCouponItemView
|
|
|
|
|
|
+- (UIImageView *)bgImaegView {
|
|
|
+ if (!_bgImaegView) {
|
|
|
+ _bgImaegView = [[UIImageView alloc] init];
|
|
|
+ _bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
|
|
|
+ }
|
|
|
+ return _bgImaegView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)couponCodeLab {
|
|
|
+ if (!_couponCodeLab) {
|
|
|
+ _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ _couponCodeLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ }
|
|
|
+ return _couponCodeLab;
|
|
|
+}
|
|
|
+
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
if (self = [super initWithFrame:frame]) {
|
|
|
|
|
|
- UIImageView *bgImaegView = [[UIImageView alloc] init];
|
|
|
- bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
|
|
|
- [self addSubview:bgImaegView];
|
|
|
- [bgImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ [self addSubview:self.bgImaegView];
|
|
|
+
|
|
|
+ [self.bgImaegView addSubview:self.couponCodeLab];
|
|
|
+
|
|
|
+
|
|
|
+ [self.bgImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.edges.mas_equalTo(0);
|
|
|
}];
|
|
|
|
|
|
- _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
- _couponCodeLab.textAlignment = NSTextAlignmentCenter;
|
|
|
- [bgImaegView addSubview:_couponCodeLab];
|
|
|
- [_couponCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.couponCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.bottom.mas_equalTo(-16);
|
|
|
- make.centerX.equalTo(bgImaegView.mas_centerX).offset(-25);
|
|
|
+ make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
|
|
|
make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
|
|
|
}];
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
return self;
|
|
|
}
|