104 lines
3.2 KiB
Objective-C
104 lines
3.2 KiB
Objective-C
//
|
|
// KBSvipBenefitCell.m
|
|
// keyBoard
|
|
//
|
|
// SVIP 权益项样式:左侧图标 + 文字 + 右侧勾选
|
|
//
|
|
|
|
#import "KBSvipBenefitCell.h"
|
|
|
|
@interface KBSvipBenefitCell ()
|
|
@property (nonatomic, strong) UIView *coverView; // 左侧图标
|
|
|
|
@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.coverView];
|
|
[self.contentView addSubview:self.iconView];
|
|
[self.coverView addSubview:self.titleLabel];
|
|
[self.coverView addSubview:self.checkView];
|
|
|
|
|
|
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(self.contentView).inset(16);
|
|
make.centerY.equalTo(self.contentView);
|
|
make.height.mas_equalTo(46);
|
|
}];
|
|
|
|
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.coverView).offset(16);
|
|
make.top.equalTo(self.contentView);
|
|
make.width.height.mas_equalTo(38);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.iconView.mas_right).offset(12);
|
|
make.centerY.equalTo(self.coverView);
|
|
make.right.lessThanOrEqualTo(self.checkView.mas_left).offset(-12);
|
|
}];
|
|
|
|
[self.checkView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(self.coverView).offset(-16);
|
|
make.centerY.equalTo(self.coverView);
|
|
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;
|
|
_checkView.image = [UIImage imageNamed:@"pay_oks_icon"];
|
|
}
|
|
return _checkView;
|
|
}
|
|
|
|
|
|
- (UIView *)coverView{
|
|
if (!_coverView) {
|
|
_coverView = [[UIView alloc] init];
|
|
_coverView.backgroundColor = [UIColor whiteColor];
|
|
_coverView.layer.cornerRadius = 8;
|
|
_coverView.layer.masksToBounds = true;
|
|
}
|
|
return _coverView;
|
|
}
|
|
|
|
@end
|