// // YXLeftTableViewCell.m // Temperature // // Created by z on 2025/1/17. // #import "YXLeftTableViewCell.h" @interface YXLeftTableViewCell () @property (nonatomic, strong) UIView *colorView; @end @implementation YXLeftTableViewCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.numberOfLines = 0; self.titleLabel.font = [UIFont boldSystemFontOfSize:13]; self.titleLabel.textColor = [UIColor colorWithHexString:@"#999999"]; self.titleLabel.highlightedTextColor = [UIColor colorWithHexString:@"#1E1E1E"]; [self.contentView addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.mas_centerY); make.left.equalTo(@10); make.right.equalTo(@10); make.height.equalTo(@30); }]; self.colorView = [[UIView alloc] init]; self.colorView.backgroundColor = [UIColor colorWithHexString:@"#267AFF"]; [self.contentView addSubview:self.colorView]; [self.colorView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.mas_centerY); make.left.equalTo(@3); make.width.equalTo(@3); make.height.equalTo(@15); }]; self.colorView.layer.cornerRadius = 1.5; } return self; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state self.contentView.backgroundColor = selected ? [UIColor whiteColor] : [UIColor colorWithHexString:@"#F9F9F9"]; self.highlighted = selected; self.titleLabel.highlighted = selected; self.titleLabel.font = selected ? [UIFont boldSystemFontOfSize:14] : [UIFont boldSystemFontOfSize:13]; self.colorView.hidden = !selected; } @end