Files
keyboard/keyBoard/Class/Pay/V/KBSvipBenefitCell.m
2026-02-04 12:48:18 +08:00

89 lines
2.8 KiB
Objective-C

//
// KBSvipBenefitCell.m
// keyBoard
//
// SVIP 权益项样式:左侧图标 + 文字 + 右侧勾选
//
#import "KBSvipBenefitCell.h"
@interface KBSvipBenefitCell ()
@property (nonatomic, strong) UIImageView *iconView; // 左侧图标
@property (nonatomic, strong) UILabel *titleLabel; // 权益文字
@property (nonatomic, strong) UIImageView *checkView; // 右侧勾选
@end
@implementation KBSvipBenefitCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.contentView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.iconView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.checkView];
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(16);
make.centerY.equalTo(self.contentView);
make.width.height.mas_equalTo(40);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.iconView.mas_right).offset(12);
make.centerY.equalTo(self.contentView);
make.right.lessThanOrEqualTo(self.checkView.mas_left).offset(-12);
}];
[self.checkView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-16);
make.centerY.equalTo(self.contentView);
make.width.height.mas_equalTo(20);
}];
}
return self;
}
- (void)configWithIcon:(NSString *)iconName title:(NSString *)title {
if (iconName.length) {
self.iconView.image = [UIImage imageNamed:iconName];
}
self.titleLabel.text = title.length ? title : @"";
}
#pragma mark - Lazy
- (UIImageView *)iconView {
if (!_iconView) {
_iconView = [UIImageView new];
_iconView.contentMode = UIViewContentModeScaleAspectFit;
_iconView.layer.cornerRadius = 8;
_iconView.clipsToBounds = YES;
}
return _iconView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [UILabel new];
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
_titleLabel.font = [KBFont regular:14];
}
return _titleLabel;
}
- (UIImageView *)checkView {
if (!_checkView) {
_checkView = [UIImageView new];
_checkView.contentMode = UIViewContentModeScaleAspectFit;
// 使用 SF Symbol 勾选图标
if (@available(iOS 13.0, *)) {
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightMedium];
_checkView.image = [UIImage systemImageNamed:@"checkmark" withConfiguration:config];
}
_checkView.tintColor = [UIColor colorWithHex:KBColorValue];
}
return _checkView;
}
@end