86 lines
3.0 KiB
Objective-C
86 lines
3.0 KiB
Objective-C
//
|
||
// KBSkinDetailHeaderCell.m
|
||
// keyBoard
|
||
//
|
||
// Created by Mac on 2025/11/8.
|
||
//
|
||
|
||
#import "KBSkinDetailHeaderCell.h"
|
||
#import "UIImageView+KBWebImage.h"
|
||
#import "KBShopThemeDetailModel.h"
|
||
|
||
@implementation KBSkinDetailHeaderCell
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
if (self = [super initWithFrame:frame]) {
|
||
self.contentView.backgroundColor = [UIColor whiteColor];
|
||
self.contentView.layer.cornerRadius = 12;
|
||
self.contentView.layer.masksToBounds = YES;
|
||
|
||
[self.contentView addSubview:self.coverView];
|
||
[self.contentView addSubview:self.leftLabel];
|
||
[self.contentView addSubview:self.rightLabel];
|
||
|
||
// 上图,16:9 比例;下方左右文案
|
||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.right.equalTo(self.contentView);
|
||
// 高度按照宽度等比(接近截图比例)
|
||
// make.height.equalTo(self.contentView.mas_width).multipliedBy(0.58);
|
||
make.height.mas_equalTo(KBFit(264));
|
||
}];
|
||
[self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.contentView).offset(0);
|
||
make.top.equalTo(self.coverView.mas_bottom).offset(10);
|
||
}];
|
||
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(self.contentView).offset(-12);
|
||
make.centerY.equalTo(self.leftLabel);
|
||
}];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)configWithDetail:(KBShopThemeDetailModel *)detail {
|
||
NSString *title = detail.themeName.length ? detail.themeName : @"Dopamine";
|
||
NSString *download = detail.themeDownload.length ? detail.themeDownload : @"0";
|
||
NSString *downloadText = [NSString stringWithFormat:@"%@: %@", KBLocalized(@"Download"), download];
|
||
self.leftLabel.text = title;
|
||
self.rightLabel.text = downloadText;
|
||
// UIImage *placeholder = [UIImage imageNamed:@"shop_headbigBg_icon"];
|
||
// if (detail.themePreviewImageUrl.length) {
|
||
[self.coverView kb_setImageURL:detail.themePreviewImageUrl placeholder:KBPlaceholderImage];
|
||
// } else {
|
||
// self.coverView.image = placeholder;
|
||
// }
|
||
}
|
||
|
||
#pragma mark - Lazy
|
||
- (UIImageView *)coverView {
|
||
if (!_coverView) {
|
||
_coverView = [[UIImageView alloc] init];
|
||
_coverView.contentMode = UIViewContentModeScaleAspectFill;
|
||
_coverView.clipsToBounds = YES;
|
||
_coverView.layer.cornerRadius = 12;
|
||
}
|
||
return _coverView;
|
||
}
|
||
- (UILabel *)leftLabel {
|
||
if (!_leftLabel) {
|
||
_leftLabel = [UILabel new];
|
||
_leftLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||
_leftLabel.font = [KBFont medium:16];
|
||
_leftLabel.text = @"Dopamine";
|
||
}
|
||
return _leftLabel;
|
||
}
|
||
- (UILabel *)rightLabel {
|
||
if (!_rightLabel) {
|
||
_rightLabel = [UILabel new];
|
||
_rightLabel.textColor = [UIColor colorWithHex:KBColorValue];
|
||
_rightLabel.font = [KBFont regular:13];
|
||
_rightLabel.textAlignment = NSTextAlignmentRight;
|
||
_rightLabel.text = @"Download: 1 Million";
|
||
}
|
||
return _rightLabel;
|
||
}
|
||
@end
|