萤石云 iOSSDK,移植跨平台相关工程
Davin
2024-12-18 a67450d72c47f400e56525125318ff1d6ca0a2e8
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
//  HDLESDetectionTypeHeaderView.m
//  EZSDK
//
//  Created by Davin on 2024/12/17.
//
 
#import "HDLESDetectionTypeHeaderView.h"
 
@interface HDLESDetectionTypeHeaderView ()
 
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UISwitch *detectionSwitch;
 
@property (nonatomic, copy)void(^switchBlock)(BOOL isSelected);
 
@end
 
@implementation HDLESDetectionTypeHeaderView
 
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self createSubviews];
    }
    return self;
}
 
- (void)createSubviews {
    [self addSubview:self.titleLabel];
    [self addSubview:self.detectionSwitch];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(16);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.detectionSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_greaterThanOrEqualTo(self.titleLabel.mas_right).offset(16);
        make.right.mas_equalTo(self.mas_right);
        make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(28);
    }];
    
    [self.detectionSwitch addTarget:self action:@selector(detectionSwitchAction:) forControlEvents:UIControlEventValueChanged];
}
 
#pragma mark - PublishMethod
- (void)configSelected:(BOOL)isSelected {
    [self.detectionSwitch setOn:isSelected];
}
 
/// 检测信息设置
/// - Parameters:
///   - detectionType: 检测类型
///   - isSelected: 是否选中
- (void)configSelected:(BOOL)isSelected switchResult:(void(^)(BOOL isSelected))result {
    self.switchBlock = result;
    [self.detectionSwitch setOn:isSelected];
}
 
 
#pragma mark - PrivateMethod
- (void)detectionSwitchAction:(UISwitch *)sender {
    if (self.switchBlock) {
        self.switchBlock(sender.isOn);
    }
}
 
#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;
        _titleLabel.text = NSLocalizedString(@"setting_action_detect", @"活动检测提醒");
    }
    return _titleLabel;
}
 
- (UISwitch *)detectionSwitch {
    if (!_detectionSwitch) {
        _detectionSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
        _detectionSwitch.on = NO;
        
    }
    return _detectionSwitch;
}
 
@end