123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- //
- // ASSettingListCell.m
- // Asteria
- //
- // Created by iOS on 2023/7/5.
- //
- #import "ASSettingListCell.h"
- @interface ASSettingListCell ()
- @property (nonatomic, strong) UIView *bgV;
- @property (nonatomic, strong) UILabel *titleLb;
- @property (nonatomic, strong) UILabel *pointsLb;
- @end
- @implementation ASSettingListCell
- - (void)setTitle:(NSString *)title points:(NSString *)points enable:(BOOL)flag {
- self.titleLb.text = title;
- self.pointsLb.text = points;
- self.moreIcon.image = flag ? [UIImage imageNamed:@"uc_more"] : nil;
- self.titleLb.textColor = [UIColor.blackColor colorWithAlphaComponent:flag ? 1 : 0.6];
- self.pointsLb.textColor = [UIColor.blackColor colorWithAlphaComponent:flag ? 1 : 0.6];
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self confgSubV];
- }
- return self;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)confgSubV {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = _F8F8F8;
-
- [self.contentView addSubview:self.bgV];
- [self.bgV addSubview:self.titleLb];
- [self.bgV addSubview:self.pointsLb];
- [self.bgV addSubview:self.moreIcon];
- [self.bgV addSubview:self.switchBtn];
-
- [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(10);
- make.left.equalTo(self.contentView).offset(10);
- make.right.equalTo(self.contentView).offset(-10);
- make.bottom.equalTo(self.contentView);
- make.height.equalTo(@60);
- }];
- [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.equalTo(self.bgV).offset(10);
- make.centerY.equalTo(self.bgV);
- }];
- [self.moreIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgV).offset(-12);
- make.width.height.equalTo(@13);
- make.centerY.equalTo(self.titleLb);
- }];
- [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.moreIcon.mas_left).offset(-10);
- make.left.equalTo(self.titleLb.mas_right).offset(30);
- make.centerY.equalTo(self.titleLb);
- make.width.greaterThanOrEqualTo(@80);
- make.height.equalTo(@14);
- }];
- [self.titleLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- [self.titleLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisVertical];
- [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
- [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgV).offset(-10);
- make.centerY.equalTo(self.bgV);
- make.width.equalTo(@60);
- make.height.equalTo(@32);
- }];
-
- }
- - (UILabel *)titleLb {
- if (!_titleLb) {
- UILabel *lb = [UILabel new];
- lb.textColor = Col_000;
- lb.font = [UIFont fontWithName:Rob_Regular size:14];
- lb.numberOfLines = 0;
- _titleLb = lb;
- }
- return _titleLb;
- }
- - (UILabel *)pointsLb {
- if (!_pointsLb) {
- UILabel *lb = [UILabel new];
- lb.textColor = Col_000;
- lb.textAlignment = NSTextAlignmentRight;
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.numberOfLines = 1;
- _pointsLb = lb;
- }
- return _pointsLb;
- }
- - (UIImageView *)moreIcon {
- if (!_moreIcon) {
- UIImageView *v = [[UIImageView alloc] init];
- v.contentMode = UIViewContentModeScaleAspectFit;
- v.image = [UIImage imageNamed:@"uc_more"];
- _moreIcon = v;
- }
- return _moreIcon;
- }
- -(UIView *)bgV {
- if (!_bgV) {
- UIView *v = [UIView new];
- v.backgroundColor = Col_FFF;
- v.layer.cornerRadius = 4;
- v.layer.masksToBounds = true;
- _bgV = v;
- }
- return _bgV;
- }
- -(KWSwitchButton *)switchBtn {
- if (!_switchBtn) {
- KWSwitchButton *btn = [[KWSwitchButton alloc] init];
- btn.openColor = _32CFB0;
- btn.hidden = true;
- _switchBtn = btn;
- }
- return _switchBtn;
- }
- @end
|