// // MOSelectPartitionCell.m // MiMoLive // // Created by SuperC on 2023/10/16. // #import "MOSelectPartitionCell.h" @implementation MOSelectPartitionCell #pragma mark - View Cycle - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor whiteColor]; _iconImg = [UIImageView new]; [self.contentView addSubview:_iconImg]; [_iconImg mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(16.0); make.centerY.equalTo(self.contentView).offset(0); make.width.equalTo(@(24.0)); make.height.equalTo(@(24.0)); }]; _titleLab = [UILabel new]; _titleLab.textColor = [MOTools colorWithHexString:@"#000000" alpha:1.0]; _titleLab.textAlignment = NSTextAlignmentLeft; _titleLab.font = [MOTextTools poppinsRegularFont:16]; [self.contentView addSubview:_titleLab]; [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.iconImg.mas_right).offset(12.0); make.centerY.equalTo(self.contentView).offset(0); make.width.greaterThanOrEqualTo(@55.0); make.height.equalTo(@(22.0)); }]; _numLab = [UILabel new]; _numLab.textColor = kBaseTextColor_1; _numLab.textAlignment = NSTextAlignmentLeft; _numLab.font = [MOTextTools poppinsRegularFont:16]; [self.contentView addSubview:_numLab]; [_numLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.titleLab.mas_right).offset(5); make.centerY.equalTo(self.contentView).offset(0); make.width.greaterThanOrEqualTo(@39.0); make.height.equalTo(@(22.0)); }]; // UIView *lineView = [[UIView alloc] init]; // lineView.backgroundColor = [MOTools colorWithHexString:@"#E5E5E5" alpha:0.3]; // [self.contentView addSubview:lineView]; // [lineView mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.contentView).offset(12.0); // make.right.equalTo(self.contentView).offset(-18.0); // make.height.mas_equalTo(1); // make.bottom.equalTo(self.contentView); // }]; } return self; } - (void)setModel:(MOCountryList *)model{ _model = model; __weak typeof(self) weakSelf = self; [self.iconImg sd_setImageWithURL:[NSURL URLWithString:model.icon2] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { __strong typeof(self) strongSelf = weakSelf; if (!strongSelf) return; if (!image) return; // [strongSelf.iconImg mas_updateConstraints:^(MASConstraintMaker *make) { // make.width.equalTo(@(image.size.width * 20.0 / image.size.height)); // }]; }]; self.titleLab.text = model.name; self.numLab.text = model.num; } - (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 } @end