GoodSleepHeadView.m
2.3 KB
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
//
// GoodSleepHeadView.m
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import "GoodSleepHeadView.h"
@interface GoodSleepHeadView ()
/// 左边竖条视图
@property (nonatomic, strong) UIView *verticalView;
/// 标题标签
@property (nonatomic, strong) UILabel *titleLab;
/// 定时器
@property (nonatomic, strong) UIButton *timerBtn;
@end
@implementation GoodSleepHeadView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self addSubview:self.verticalView];
[self addSubview:self.titleLab];
[self addSubview:self.timerBtn];
[self.verticalView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).offset(15);
make.top.equalTo(self.mas_top).offset(33);
make.width.equalTo(@4);
make.height.equalTo(@16);
}];
[self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.verticalView.mas_right).offset(8);
make.centerY.equalTo(self.verticalView.mas_centerY);
}];
[self.timerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.mas_right).offset(-15);
make.width.equalTo(@40);
make.height.equalTo(@30);
make.centerY.equalTo(self.verticalView.mas_centerY);
}];
}
return self;
}
#pragma mark - Actions
- (void)timerSetting:(UIButton *)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:NoiseTimingDidClick object:nil];
}
#pragma mark - lazy
- (UIView *)verticalView {
if (!_verticalView) {
_verticalView = [UIView new];
_verticalView.backgroundColor = BrandColor;
[_verticalView cornerRadius:2.0];
}
return _verticalView;
}
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [UILabel dkLabWithText:@"好眠声音" font:BoldFont(16.0)];
}
return _titleLab;
}
- (UIButton *)timerBtn {
if (!_timerBtn) {
_timerBtn = [UIButton new];
[_timerBtn dk_setImage:DKImagePickerWithNames(@"timerIcon", @"timerIcon_dk", @"timerIcon_dk") forState:UIControlStateNormal];
[_timerBtn addTarget:self action:@selector(timerSetting:) forControlEvents:UIControlEventTouchUpInside];
}
return _timerBtn;
}
@end