This commit is contained in:
2025-11-17 14:53:23 +08:00
parent d9bfc30c88
commit 1d215ffdb3
19 changed files with 208 additions and 39 deletions

View File

@@ -4,18 +4,19 @@
//
#import "KBSkinCardCell.h"
#import "KBMoneyBtn.h"
@interface KBSkinCardCell ()
@property (nonatomic, strong) UIImageView *coverView; //
@property (nonatomic, strong) UILabel *titleLabel; //
@property (nonatomic, strong) UILabel *priceLabel; //
@property (nonatomic, strong) KBMoneyBtn *priceBtn; //
@end
@implementation KBSkinCardCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.contentView.backgroundColor = [UIColor whiteColor];
self.contentView.backgroundColor = [UIColor colorWithHex:0xF8F8F8];
self.contentView.layer.cornerRadius = 12;
self.contentView.layer.masksToBounds = YES;
self.contentView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.06].CGColor;
@@ -24,22 +25,23 @@
[self.contentView addSubview:self.coverView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.priceLabel];
[self.contentView addSubview:self.priceBtn];
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.contentView);
make.height.equalTo(self.contentView.mas_width).multipliedBy(0.75); // 4:3
make.height.mas_equalTo(KBFit(126));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(12);
make.right.equalTo(self.contentView).offset(-12);
make.top.equalTo(self.coverView.mas_bottom).offset(8);
make.top.equalTo(self.coverView.mas_bottom).offset(KBFit(8));
make.height.mas_equalTo(KBFit(20));
}];
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
[self.priceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel);
make.bottom.equalTo(self.contentView).offset(-10);
make.bottom.equalTo(self.contentView).offset(-12);
}];
}
return self;
@@ -47,7 +49,8 @@
- (void)configWithTitle:(NSString *)title imageURL:(NSString *)url price:(NSString *)price {
self.titleLabel.text = title.length ? title : @"Dopamine";
self.priceLabel.text = price.length ? price : @"20";
[self.priceBtn setTitle:@"20" forState:UIControlStateNormal];
//
self.coverView.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0];
}
@@ -68,18 +71,16 @@
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
}
return _titleLabel;
}
- (UILabel *)priceLabel {
if (!_priceLabel) {
_priceLabel = [[UILabel alloc] init];
_priceLabel.font = [UIFont systemFontOfSize:14];
_priceLabel.textColor = [UIColor colorWithRed:0.15 green:0.72 blue:0.62 alpha:1.0];
- (KBMoneyBtn *)priceBtn {
if (!_priceBtn) {
_priceBtn = [KBMoneyBtn buttonWithType:UIButtonTypeCustom];
}
return _priceLabel;
return _priceBtn;
}
@end