// // KBSkinDetailHeaderCell.m // keyBoard // // Created by Mac on 2025/11/8. // #import "KBSkinDetailHeaderCell.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); }]; [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(12); 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)configWithTitle:(NSString *)title right:(NSString *)right { // 演示:标题/下载量文案 self.leftLabel.text = title.length ? title : @"Dopamine"; self.rightLabel.text = right.length ? right : @"Download: 1 Million"; // 本示例不做网络图,直接用占位背景色 self.coverView.backgroundColor = [UIColor colorWithWhite:0.94 alpha:1.0]; } #pragma mark - Lazy - (UIImageView *)coverView { if (!_coverView) { _coverView = [[UIImageView alloc] init]; _coverView.contentMode = UIViewContentModeScaleAspectFill; _coverView.clipsToBounds = YES; } return _coverView; } - (UILabel *)leftLabel { if (!_leftLabel) { _leftLabel = [UILabel new]; _leftLabel.textColor = [UIColor colorWithHex:0x1B1F1A]; _leftLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold]; _leftLabel.text = @"Dopamine"; } return _leftLabel; } - (UILabel *)rightLabel { if (!_rightLabel) { _rightLabel = [UILabel new]; _rightLabel.textColor = [UIColor colorWithHex:KBColorValue]; _rightLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; _rightLabel.textAlignment = NSTextAlignmentRight; _rightLabel.text = @"Download: 1 Million"; } return _rightLabel; } @end