This commit is contained in:
2026-02-04 15:40:45 +08:00
parent 7c7e2477cb
commit c1b50b407d
13 changed files with 146 additions and 32 deletions

View File

@@ -8,10 +8,12 @@
#import "KBSvipSubscribeCell.h"
@interface KBSvipSubscribeCell ()
@property (nonatomic, strong) UIImageView *bgImageView; //
@property (nonatomic, strong) UILabel *titleLabel; // "1 Week" / "1 Month" / "1 Year"
@property (nonatomic, strong) UILabel *priceLabel; // "$6.90"
@property (nonatomic, strong) UILabel *strikeLabel; // 线
@property (nonatomic, strong) UIImageView *bgImageView; //
@property (nonatomic, strong) UILabel *titleLabel; // "1 Week" / "1 Month" / "1 Year"
@property (nonatomic, strong) UIView *priceContainer; //
@property (nonatomic, strong) UILabel *currencyLabel; // "$"
@property (nonatomic, strong) UILabel *priceLabel; // "6.90"
@property (nonatomic, strong) UILabel *strikeLabel; // 线
@end
@implementation KBSvipSubscribeCell
@@ -26,19 +28,38 @@
}];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.priceLabel];
[self.contentView addSubview:self.strikeLabel];
[self.contentView addSubview:self.priceContainer];
//
[self.priceContainer addSubview:self.currencyLabel];
[self.priceContainer addSubview:self.priceLabel];
[self.priceContainer addSubview:self.strikeLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.contentView).offset(12);
make.top.equalTo(self.contentView).offset(10);
}];
[self.priceContainer mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(5);
make.right.equalTo(self.contentView).offset(-5);
make.bottom.equalTo(self.contentView).offset(-5);
make.height.mas_equalTo(86);
}];
//
[self.currencyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.priceLabel.mas_left).offset(-2);
make.bottom.equalTo(self.priceLabel.mas_bottom).offset(-4); //
}];
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.titleLabel.mas_bottom).offset(8);
make.centerX.equalTo(self.priceContainer).offset(6); //
make.centerY.equalTo(self.priceContainer).offset(-8);
}];
[self.strikeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.centerX.equalTo(self.priceContainer);
make.top.equalTo(self.priceLabel.mas_bottom).offset(4);
}];
}
@@ -55,9 +76,10 @@
[self applySelected:selected animated:NO];
}
- (void)configTitle:(NSString *)title price:(NSString *)price strike:(nullable NSString *)strike {
- (void)configTitle:(NSString *)title currency:(NSString *)currency price:(NSString *)price strike:(nullable NSString *)strike {
self.titleLabel.text = title.length ? title : @"1 Month";
self.priceLabel.text = price.length ? price : @"$6.90";
self.currencyLabel.text = currency.length ? currency : @"$";
self.priceLabel.text = price.length ? price : @"6.90";
self.strikeLabel.hidden = (strike.length == 0);
if (strike.length) {
NSDictionary *attr = @{
@@ -68,6 +90,11 @@
}
}
//
- (void)configTitle:(NSString *)title price:(NSString *)price strike:(nullable NSString *)strike {
[self configTitle:title currency:@"$" price:price strike:strike];
}
- (void)applySelected:(BOOL)selected animated:(BOOL)animated {
NSString *imageName = selected ? @"pay_colorbg_icon" : @"pay_graybg_icon";
void (^changes)(void) = ^{
@@ -101,12 +128,32 @@
return _titleLabel;
}
- (UIView *)priceContainer {
if (!_priceContainer) {
_priceContainer = [UIView new];
_priceContainer.backgroundColor = [UIColor whiteColor];
_priceContainer.layer.cornerRadius = 14;
_priceContainer.clipsToBounds = YES;
}
return _priceContainer;
}
- (UILabel *)currencyLabel {
if (!_currencyLabel) {
_currencyLabel = [UILabel new];
_currencyLabel.text = @"$";
_currencyLabel.textColor = [UIColor colorWithHex:KBBlackValue];
_currencyLabel.font = [KBFont medium:14]; //
}
return _currencyLabel;
}
- (UILabel *)priceLabel {
if (!_priceLabel) {
_priceLabel = [UILabel new];
_priceLabel.text = @"$6.90";
_priceLabel.text = @"6.90";
_priceLabel.textColor = [UIColor colorWithHex:KBBlackValue];
_priceLabel.font = [KBFont bold:22];
_priceLabel.font = [KBFont bold:22]; //
}
return _priceLabel;
}