// // HDLEZDetectionTypeCell.m // EZSDK // // Created by Davin on 2023/8/5. // #import "HDLEZDetectionTypeCell.h" @interface HDLEZDetectionTypeCell () @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UIImageView *selectedIcon; @end @implementation HDLEZDetectionTypeCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self createSubviews]; } return self; } - (void)createSubviews { self.backgroundColor = [UIColor whiteColor]; self.contentView.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.selectedIcon]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.contentView.mas_left).offset(16); make.centerY.mas_equalTo(self.contentView.mas_centerY); }]; [self.selectedIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.titleLabel.mas_right).offset(16); make.right.mas_equalTo(self.contentView.mas_right).offset(-25.); make.centerY.mas_equalTo(self.titleLabel.mas_centerY); make.width.height.mas_equalTo(23); }]; } #pragma mark - PublishMethod - (void)configDetectionType:(NSString *)detectionType selected:(BOOL)isSelected { self.titleLabel.text = detectionType ? : @""; if (isSelected) { [self.selectedIcon setImage:[UIImage imageNamed:@"hdl_ez_detection_selected"]]; } else { [self.selectedIcon setImage:[UIImage imageNamed:@"hdl_ez_detection_normal"]]; } } #pragma mark - Getter - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel=[[UILabel alloc] init]; _titleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14); _titleLabel.textColor=HDLEZ_COLOR_TITLE_BLACK; } return _titleLabel; } - (UIImageView *)selectedIcon { if (!_selectedIcon) { _selectedIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hdl_ez_detection_normal"]]; _selectedIcon.contentMode = UIViewContentModeScaleAspectFill; _selectedIcon.backgroundColor = UIColor.clearColor; } return _selectedIcon; } @end