CNLiveBoxWIFITipAlertView.m
5.81 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//
// CNLiveBoxTipAlertView.m
// CNLiveNetAdd
//
// Created by 梁星国 on 2019/9/19.
// Copyright © 2019 cnlive. All rights reserved.
//
#import "CNLiveBoxWIFITipAlertView.h"
#define kWIFITipViewW 270
#define kWIFITipViewH 151
@implementation CNLiveBoxWIFITipAlertView
//提示
+ (CNLiveBoxWIFITipAlertView *)showAlertAddedTo:(UIView *)view{
CNLiveBoxWIFITipAlertView *alertView = [[CNLiveBoxWIFITipAlertView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
alertView.alpha = 0.5;
[view addSubview:alertView];
return alertView;
}
- (void)showAlerView {
self.alpha = 0.5;
[UIView animateWithDuration:0.3 animations:^{
self.alpha = 1;
}];
}
- (void)hiddenAlerView {
[UIView animateWithDuration:0.3 animations:^{
self.alpha = 0.3;
[self removeFromSuperview];
}];
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = RGBACOLOR(51, 51, 51, 0.3);
[self setupUI];
[self layoutUI];
}
return self;
}
- (void)setupUI {
[self addSubview:self.bgView];
[self.bgView addSubview:self.enterTF];
[self.bgView addSubview:self.showPWBtn];
[self.bgView addSubview:self.bottomLineV];
[self.bgView addSubview:self.contenL];
[self.bgView addSubview:self.cancleBtn];
[self.bgView addSubview:self.sureBtn];
[self.bgView addSubview:self.horizontalLine];
[self.bgView addSubview:self.verticalLine];
}
- (void)layoutUI {
self.bgView.frame = CGRectMake((KScreenWidth - kWIFITipViewW)/2, (KScreenHeight - kWIFITipViewH)/2, kWIFITipViewW, kWIFITipViewH);
self.contenL.frame = CGRectMake(10, 21, kWIFITipViewW - 20, 17);
self.showPWBtn.frame = CGRectMake(kWIFITipViewW - 50 , self.contenL.bottom + 15, 40, 38);
self.enterTF.frame = CGRectMake(20, self.showPWBtn.centerY - 19, kWIFITipViewW - 80, 38);
self.bottomLineV.frame = CGRectMake(20, self.showPWBtn.bottom + 1, kWIFITipViewW - 40, 0.5);
self.horizontalLine.frame = CGRectMake(0, kWIFITipViewH - 44, kWIFITipViewW, 0.5);
self.verticalLine.frame = CGRectMake(kWIFITipViewW/2, kWIFITipViewH - 44, 0.5, 44);
self.cancleBtn.frame = CGRectMake(0, kWIFITipViewH - 43, kWIFITipViewW/2, 43);
self.sureBtn.frame = CGRectMake(kWIFITipViewW/2, kWIFITipViewH - 43, kWIFITipViewW/2, 43);
[self.bgView setBackgroundColor:[UIColor whiteColor]];
}
#pragma mark - 实现
- (void)showPWBtnAction:(UIButton *)sender {
}
- (void)sureBtnAction:(UIButton *)sender {
}
- (void)cancleBtnAction:(UIButton *)sender {
}
#pragma mark - 属性
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc]initWithFrame:CGRectZero];
[_bgView setBackgroundColor:[UIColor whiteColor]];
_bgView.layer.masksToBounds = YES;
_bgView.layer.cornerRadius = 15;
}
return _bgView;
}
- (UITextField *)enterTF {
if (!_enterTF) {
_enterTF = [[UITextField alloc]initWithFrame:CGRectZero];
}
return _enterTF;
}
- (UIButton *)showPWBtn {
if (!_showPWBtn) {
_showPWBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_showPWBtn setTitle:@"取消" forState:UIControlStateNormal];
[_showPWBtn setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
_showPWBtn.titleLabel.font = [UIFont systemFontOfSize:16];
_showPWBtn.backgroundColor = [UIColor clearColor];
[_showPWBtn addTarget:self action:@selector(showPWBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancleBtn;
}
- (UIView *)bottomLineV {
if (!_bottomLineV) {
_bottomLineV = [[UIView alloc]initWithFrame:CGRectZero];
}
return _bottomLineV;
}
- (UILabel *)contenL {
if (!_contenL) {
_contenL = [[UILabel alloc]initWithFrame:CGRectZero];
_contenL.textColor = [UIColor blackColor];
_contenL.font = [UIFont systemFontOfSize:17];
}
return _contenL;
}
- (UIView *)horizontalLine {
if (!_horizontalLine) {
_horizontalLine = [[UIView alloc]initWithFrame:CGRectZero];
[_horizontalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
}
return _horizontalLine;
}
- (UIView *)verticalLine {
if (!_verticalLine) {
_verticalLine = [[UIView alloc]initWithFrame:CGRectZero];
[_verticalLine setBackgroundColor:RGBCOLOR(199, 199, 199)];
}
return _verticalLine;
}
- (UIButton *)cancleBtn {
if (!_cancleBtn) {
_cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
[_cancleBtn setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
_cancleBtn.titleLabel.font = [UIFont systemFontOfSize:16];
_cancleBtn.backgroundColor = [UIColor clearColor];
[_cancleBtn addTarget:self action:@selector(cancleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancleBtn;
}
- (UIButton *)sureBtn {
if (!_sureBtn) {
_sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
[_sureBtn setTitleColor:RGBCOLOR(11, 190, 6) forState:UIControlStateNormal];
_sureBtn.titleLabel.font = [UIFont systemFontOfSize:16];
_sureBtn.backgroundColor = [UIColor clearColor];
[_sureBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sureBtn;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//获取手指触摸view是的任意一个触摸对象
UITouch * touch = [touches anyObject];
//获取是手指触摸的view
UIView *view = [touch view];
if ([view isEqual:self]) {
[self hiddenAlerView];
}
}
@end