萤石云 iOSSDK,移植跨平台相关工程
Davin
2024-06-07 4c1abca185a5727da6fb314a0cb4cd44bfe1b3bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
//  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