|
@ -7,6 +7,20 @@
|
7
|
7
|
//
|
8
|
8
|
|
9
|
9
|
#import "WDFTipsHUD.h"
|
|
10
|
#import <WadeMobile/UIViewAdditions.h>
|
|
11
|
#import <WadeMobile/WDCommonTool.h>
|
|
12
|
//屏幕高度
|
|
13
|
#define deviceHeight ([[UIScreen mainScreen] bounds].size.height)
|
|
14
|
//屏幕宽度
|
|
15
|
#define deviceWidth ([[UIScreen mainScreen] bounds].size.width)
|
|
16
|
|
|
17
|
@interface WDFTipsHUD()
|
|
18
|
{
|
|
19
|
UITextField *inputField;
|
|
20
|
}
|
|
21
|
|
|
22
|
|
|
23
|
@end
|
10
|
24
|
|
11
|
25
|
@implementation WDFTipsHUD
|
12
|
26
|
|
|
@ -15,10 +29,9 @@
|
15
|
29
|
*/
|
16
|
30
|
-(void)showLoadingHUD:(NSArray *)params{
|
17
|
31
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
18
|
|
if (vc.ipuHud==nil) {
|
19
|
|
IPUProgressHUD *hud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
20
|
|
[vc.view addSubview:hud];
|
21
|
|
}
|
|
32
|
vc.ipuHud = nil;
|
|
33
|
vc.ipuHud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
|
34
|
[vc.view addSubview:vc.ipuHud];
|
22
|
35
|
vc.ipuHud.mode = IPUProgressHUDModeIndeterminate;
|
23
|
36
|
vc.ipuHud.margin = 20.0f;
|
24
|
37
|
vc.ipuHud.labelText = nil;
|
|
@ -44,7 +57,7 @@
|
44
|
57
|
return;
|
45
|
58
|
}
|
46
|
59
|
NSString *txt = params[0];
|
47
|
|
NSTimeInterval time = 1;
|
|
60
|
NSTimeInterval time = 2;
|
48
|
61
|
if (params.count>1 && params[1]!=[NSNull null]) {
|
49
|
62
|
NSString *timeStr = params[1];
|
50
|
63
|
time = timeStr.doubleValue;
|
|
@ -53,14 +66,353 @@
|
53
|
66
|
}
|
54
|
67
|
}
|
55
|
68
|
/*
|
|
69
|
外部JS访问:showCustomAlert插件显示一个可动态配置的弹出框,内容与确认按钮必须显示,标题与取消按钮通过参数配置决定是否显示
|
|
70
|
params[0]:提示框内容(字符串类型,不能为空)
|
|
71
|
params[1]:提示框标题(字符串类型,可以为空)
|
|
72
|
params[2]:是否显示两个按钮“取消、确认”供选择(布尔类型,true—取消、确认,false—确认)
|
|
73
|
params[3]:提示框文字颜色设置(数组类型,第一个为普通颜色值,第二个为提亮颜色值)
|
|
74
|
*/
|
|
75
|
-(void)showCustomAlert:(NSArray *)params{
|
|
76
|
NSString *text = nil;
|
|
77
|
NSString *title = nil;
|
|
78
|
BOOL isChooseAlert = false;
|
|
79
|
NSArray *colors = nil;
|
|
80
|
if (params && params.count>0) {
|
|
81
|
if (params[0]==[NSNull null]) {
|
|
82
|
return;
|
|
83
|
}
|
|
84
|
text = params[0];
|
|
85
|
if (params.count>1 && params[1]!=[NSNull null]) {
|
|
86
|
title = params[1];
|
|
87
|
}
|
|
88
|
if (params.count>2 && params[2]!=[NSNull null]) {
|
|
89
|
isChooseAlert = [params[2] boolValue];
|
|
90
|
}
|
|
91
|
if (params.count>3 && params[3]!=[NSNull null]) {
|
|
92
|
colors = params[3];
|
|
93
|
}
|
|
94
|
}
|
|
95
|
|
|
96
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 0, deviceWidth-100, 204)];
|
|
97
|
if (title==nil) {
|
|
98
|
view.frame = CGRectMake(50, 0, deviceWidth-100, 140);
|
|
99
|
}
|
|
100
|
view.layer.cornerRadius = 2;
|
|
101
|
|
|
102
|
//标题控件
|
|
103
|
UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, view.width, 64)];
|
|
104
|
titleLbl.font = [UIFont boldSystemFontOfSize:20];
|
|
105
|
titleLbl.textAlignment = NSTextAlignmentCenter;
|
|
106
|
if (colors && colors.count>0) {
|
|
107
|
titleLbl.textColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
108
|
}else{
|
|
109
|
titleLbl.textColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
110
|
}
|
|
111
|
[view addSubview:titleLbl];
|
|
112
|
if (title) {
|
|
113
|
titleLbl.hidden = NO;
|
|
114
|
titleLbl.text = title;
|
|
115
|
}else{
|
|
116
|
titleLbl.hidden = YES;
|
|
117
|
}
|
|
118
|
|
|
119
|
//内容控件
|
|
120
|
UILabel *contentLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, view.width-40, 0)];
|
|
121
|
contentLbl.font = [UIFont systemFontOfSize:16];
|
|
122
|
if (colors && colors.count>0) {
|
|
123
|
contentLbl.textColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
124
|
}else{
|
|
125
|
contentLbl.textColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
126
|
}
|
|
127
|
//换行
|
|
128
|
contentLbl.numberOfLines = 0;
|
|
129
|
contentLbl.lineBreakMode = NSLineBreakByWordWrapping;
|
|
130
|
contentLbl.text = text;
|
|
131
|
//设置行距
|
|
132
|
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
|
|
133
|
paragraphStyle.lineSpacing = 5;
|
|
134
|
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
|
|
135
|
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
|
|
136
|
contentLbl.attributedText = [[NSAttributedString alloc] initWithString:contentLbl.text attributes:attributes];
|
|
137
|
[view addSubview:contentLbl];
|
|
138
|
CGSize size = [contentLbl.text sizeWithFont: contentLbl.font constrainedToSize:CGSizeMake(contentLbl.width,200)];
|
|
139
|
//计算文字行数
|
|
140
|
CGSize size1 = [@"一行文字高度" sizeWithFont: contentLbl.font constrainedToSize:CGSizeMake(contentLbl.width,200)];
|
|
141
|
int textRow = size.height/size1.height-1;
|
|
142
|
if (size.height>20) {
|
|
143
|
contentLbl.textAlignment = NSTextAlignmentLeft;
|
|
144
|
}else{
|
|
145
|
contentLbl.textAlignment = NSTextAlignmentCenter;
|
|
146
|
}
|
|
147
|
if (title) {
|
|
148
|
CGRect rect = contentLbl.frame;
|
|
149
|
rect.origin.y = titleLbl.bottom;
|
|
150
|
rect.size.height = size.height+5*textRow;//加上间距高度
|
|
151
|
contentLbl.frame = rect;
|
|
152
|
view.frame = CGRectMake(50, 0, deviceWidth-100, titleLbl.height+contentLbl.height+30+60);
|
|
153
|
}else{
|
|
154
|
CGRect rect = contentLbl.frame;
|
|
155
|
rect.origin.y = 30;
|
|
156
|
rect.size.height = size.height+5*textRow;
|
|
157
|
contentLbl.frame = rect;
|
|
158
|
view.frame = CGRectMake(50, 0, deviceWidth-100, 30+contentLbl.height+30+60);
|
|
159
|
}
|
|
160
|
|
|
161
|
//横线
|
|
162
|
UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(0, view.height-60, view.width, 0.5)];
|
|
163
|
if (colors && colors.count>0) {
|
|
164
|
hLine.backgroundColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
165
|
}else{
|
|
166
|
hLine.backgroundColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
167
|
}
|
|
168
|
[view addSubview:hLine];
|
|
169
|
|
|
170
|
if (isChooseAlert) {//可选择弹出框
|
|
171
|
//竖线
|
|
172
|
UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(view.width/2, view.height-59.5, 0.5, 59.5)];
|
|
173
|
if (colors && colors.count>0) {
|
|
174
|
vLine.backgroundColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
175
|
}else{
|
|
176
|
vLine.backgroundColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
177
|
}
|
|
178
|
[view addSubview:vLine];
|
|
179
|
|
|
180
|
UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
181
|
cancelBtn.frame = CGRectMake(0, view.height-59.5, view.width/2, vLine.height);
|
|
182
|
[cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
|
|
183
|
if (colors && colors.count>0) {
|
|
184
|
[cancelBtn setTitleColor:[WDCommonTool convertHexToColor:colors[0]] forState:UIControlStateNormal];
|
|
185
|
}else{
|
|
186
|
[cancelBtn setTitleColor:[WDCommonTool convertHexToColor:@"#061B36"] forState:UIControlStateNormal];
|
|
187
|
}
|
|
188
|
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
189
|
[cancelBtn addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
190
|
[view addSubview:cancelBtn];
|
|
191
|
|
|
192
|
UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
193
|
addBtn.frame = CGRectMake(view.width/2, view.height-59.5, view.width/2, vLine.height);
|
|
194
|
[addBtn setTitle:@"确定" forState:UIControlStateNormal];
|
|
195
|
if (colors && colors.count>1) {
|
|
196
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:colors[1]] forState:UIControlStateNormal];
|
|
197
|
}else{
|
|
198
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:@"#07B57A"] forState:UIControlStateNormal];
|
|
199
|
}
|
|
200
|
addBtn.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
201
|
[addBtn addTarget:self action:@selector(okAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
202
|
[view addSubview:addBtn];
|
|
203
|
}else{
|
|
204
|
UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
205
|
addBtn.frame = CGRectMake(0, view.height-59.5, view.width, 59.5);
|
|
206
|
[addBtn setTitle:@"确定" forState:UIControlStateNormal];
|
|
207
|
if (colors && colors.count>1) {
|
|
208
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:colors[1]] forState:UIControlStateNormal];
|
|
209
|
}else{
|
|
210
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:@"#07B57A"] forState:UIControlStateNormal];
|
|
211
|
}
|
|
212
|
addBtn.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
213
|
[addBtn addTarget:self action:@selector(okAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
214
|
[view addSubview:addBtn];
|
|
215
|
}
|
|
216
|
|
|
217
|
[self showHUDWithCustomView:view];
|
|
218
|
}
|
|
219
|
/*
|
|
220
|
外部JS访问:显示一个带输入框的弹出框,内容、输入框、“取消、提交”按钮是必须显示的,标题通过参数配置决定是否显示
|
|
221
|
params[0]:提示框内容(字符串类型,不能为空)
|
|
222
|
params[1]:提示框标题(字符串类型,可以为空)
|
|
223
|
params[2]:输入文字内容是否为暗文(布尔类型,true为暗文,false为明文)
|
|
224
|
params[3]:提示框文字颜色设置(数组类型,第一个为普通颜色值,第二个为提亮颜色值)
|
|
225
|
*/
|
|
226
|
-(void)showInputAlert:(NSArray *)params{
|
|
227
|
NSString *text = nil;
|
|
228
|
NSString *title = nil;
|
|
229
|
BOOL isSecure = false;
|
|
230
|
NSArray *colors = nil;
|
|
231
|
if (params && params.count>0) {
|
|
232
|
if (params[0]==[NSNull null]) {
|
|
233
|
return;
|
|
234
|
}
|
|
235
|
text = params[0];
|
|
236
|
if (params.count>1 && params[1]!=[NSNull null]) {
|
|
237
|
title = params[1];
|
|
238
|
}
|
|
239
|
if (params.count>2 && params[2]!=[NSNull null]) {
|
|
240
|
isSecure = [params[2] boolValue];
|
|
241
|
}
|
|
242
|
if (params.count>3 && params[3]!=[NSNull null]) {
|
|
243
|
colors = params[3];
|
|
244
|
}
|
|
245
|
}
|
|
246
|
|
|
247
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 0, deviceWidth-100, 204)];
|
|
248
|
view.frame = CGRectMake(50, 0, deviceWidth-100, 140);
|
|
249
|
view.layer.cornerRadius = 2;
|
|
250
|
|
|
251
|
//标题控件
|
|
252
|
UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, view.width, 64)];
|
|
253
|
titleLbl.font = [UIFont boldSystemFontOfSize:20];
|
|
254
|
titleLbl.textAlignment = NSTextAlignmentCenter;
|
|
255
|
if (colors && colors.count>0) {
|
|
256
|
titleLbl.textColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
257
|
}else{
|
|
258
|
titleLbl.textColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
259
|
}
|
|
260
|
titleLbl.text = title;
|
|
261
|
[view addSubview:titleLbl];
|
|
262
|
|
|
263
|
//内容控件
|
|
264
|
UILabel *contentLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, titleLbl.bottom, view.width-40, 0)];
|
|
265
|
contentLbl.font = [UIFont systemFontOfSize:16];
|
|
266
|
if (colors && colors.count>0) {
|
|
267
|
contentLbl.textColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
268
|
}else{
|
|
269
|
contentLbl.textColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
270
|
}
|
|
271
|
//换行
|
|
272
|
contentLbl.numberOfLines = 0;
|
|
273
|
contentLbl.lineBreakMode = NSLineBreakByWordWrapping;
|
|
274
|
contentLbl.text = text;
|
|
275
|
//设置行距
|
|
276
|
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
|
|
277
|
paragraphStyle.lineSpacing = 5;
|
|
278
|
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
|
|
279
|
[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
|
|
280
|
contentLbl.attributedText = [[NSAttributedString alloc] initWithString:contentLbl.text attributes:attributes];
|
|
281
|
[view addSubview:contentLbl];
|
|
282
|
CGSize size = [contentLbl.text sizeWithFont: contentLbl.font constrainedToSize:CGSizeMake(contentLbl.width,200)];
|
|
283
|
//计算文字行数
|
|
284
|
CGSize size1 = [@"一行文字高度" sizeWithFont: contentLbl.font constrainedToSize:CGSizeMake(contentLbl.width,200)];
|
|
285
|
int textRow = size.height/size1.height-1;
|
|
286
|
if (textRow>0) {
|
|
287
|
contentLbl.textAlignment = NSTextAlignmentLeft;
|
|
288
|
}else{
|
|
289
|
contentLbl.textAlignment = NSTextAlignmentCenter;
|
|
290
|
}
|
|
291
|
CGRect rect = contentLbl.frame;
|
|
292
|
rect.origin.y = titleLbl.bottom;
|
|
293
|
rect.size.height = size.height+5*textRow;//加上间距高度
|
|
294
|
contentLbl.frame = rect;
|
|
295
|
|
|
296
|
//输入框
|
|
297
|
inputField = [[UITextField alloc] initWithFrame:CGRectMake(20, contentLbl.bottom+20, view.width-40, 40)];
|
|
298
|
if (colors && colors.count>1) {
|
|
299
|
inputField.layer.borderColor = [WDCommonTool convertHexToColor:colors[1]].CGColor;
|
|
300
|
}else{
|
|
301
|
inputField.layer.borderColor = [WDCommonTool convertHexToColor:@"#061B36"].CGColor;
|
|
302
|
}
|
|
303
|
inputField.layer.borderWidth = 1;
|
|
304
|
inputField.layer.cornerRadius = 2;
|
|
305
|
inputField.textColor = contentLbl.textColor;
|
|
306
|
inputField.font = contentLbl.font;
|
|
307
|
inputField.secureTextEntry = isSecure;
|
|
308
|
[view addSubview:inputField];
|
|
309
|
|
|
310
|
//横线
|
|
311
|
UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(0, inputField.bottom+30, view.width, 0.5)];
|
|
312
|
if (colors && colors.count>0) {
|
|
313
|
hLine.backgroundColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
314
|
}else{
|
|
315
|
hLine.backgroundColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
316
|
}
|
|
317
|
[view addSubview:hLine];
|
|
318
|
|
|
319
|
//竖线
|
|
320
|
UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(view.width/2, hLine.bottom, 0.5, 59.5)];
|
|
321
|
if (colors && colors.count>0) {
|
|
322
|
vLine.backgroundColor = [WDCommonTool convertHexToColor:colors[0]];
|
|
323
|
}else{
|
|
324
|
vLine.backgroundColor = [WDCommonTool convertHexToColor:@"#061B36"];
|
|
325
|
}
|
|
326
|
[view addSubview:vLine];
|
|
327
|
|
|
328
|
//取消按钮
|
|
329
|
UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
330
|
cancelBtn.frame = CGRectMake(0, hLine.bottom, view.width/2, vLine.height);
|
|
331
|
[cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
|
|
332
|
if (colors && colors.count>0) {
|
|
333
|
[cancelBtn setTitleColor:[WDCommonTool convertHexToColor:colors[0]] forState:UIControlStateNormal];
|
|
334
|
}else{
|
|
335
|
[cancelBtn setTitleColor:[WDCommonTool convertHexToColor:@"#061B36"] forState:UIControlStateNormal];
|
|
336
|
}
|
|
337
|
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
338
|
[cancelBtn addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
339
|
[view addSubview:cancelBtn];
|
|
340
|
|
|
341
|
//提交按钮
|
|
342
|
UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
343
|
addBtn.frame = CGRectMake(view.width/2, hLine.bottom, view.width/2, vLine.height);
|
|
344
|
[addBtn setTitle:@"提交" forState:UIControlStateNormal];
|
|
345
|
if (colors && colors.count>1) {
|
|
346
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:colors[1]] forState:UIControlStateNormal];
|
|
347
|
}else{
|
|
348
|
[addBtn setTitleColor:[WDCommonTool convertHexToColor:@"#07B57A"] forState:UIControlStateNormal];
|
|
349
|
}
|
|
350
|
addBtn.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
351
|
[addBtn addTarget:self action:@selector(submitAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
352
|
[view addSubview:addBtn];
|
|
353
|
|
|
354
|
view.frame = CGRectMake(50, 0, deviceWidth-100, titleLbl.height+contentLbl.height+20+inputField.height+30+60);
|
|
355
|
|
|
356
|
[self showHUDWithCustomView:view];
|
|
357
|
}
|
|
358
|
/*
|
|
359
|
外部JS访问:显示一个带“成功图标+文字”的提示框,持续指定时长后隐藏
|
|
360
|
params[0]:提示框显示的时长(可为空,默认持续2秒)
|
|
361
|
*/
|
|
362
|
-(void)showSuccessHUD:(NSArray *)params{
|
|
363
|
NSTimeInterval time = 2;
|
|
364
|
if (params && params.count>0 && params[0]!=[NSNull null]) {
|
|
365
|
NSString *timeStr = params[0];
|
|
366
|
time = timeStr.doubleValue;
|
|
367
|
}
|
|
368
|
|
|
369
|
NSString *bundlestring = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/WadeMobileFuncBundle.bundle"];
|
|
370
|
NSBundle *bundle = [NSBundle bundleWithPath:bundlestring];
|
|
371
|
UIImage *successImg = [UIImage imageNamed:@"success" inBundle:bundle compatibleWithTraitCollection:nil];
|
|
372
|
|
|
373
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 95)];
|
|
374
|
view.layer.cornerRadius = 5;
|
|
375
|
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, view.width, view.height)];
|
|
376
|
imgView.image = successImg;
|
|
377
|
[view addSubview:imgView];
|
|
378
|
|
|
379
|
[self showHUDWithImageView:view DisplayTime:time];
|
|
380
|
|
|
381
|
}
|
|
382
|
/*
|
|
383
|
外部JS访问:显示一个带“失败图标+文字”的提示框,持续指定时长后隐藏
|
|
384
|
params[0]:提示框显示的时长(可为空,默认持续2秒)
|
|
385
|
*/
|
|
386
|
-(void)showFailHUD:(NSArray *)params{
|
|
387
|
NSTimeInterval time = 2;
|
|
388
|
if (params && params.count>0 && params[0]!=[NSNull null]) {
|
|
389
|
NSString *timeStr = params[0];
|
|
390
|
time = timeStr.doubleValue;
|
|
391
|
}
|
|
392
|
|
|
393
|
NSString *bundlestring = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/WadeMobileFuncBundle.bundle"];
|
|
394
|
NSBundle *bundle = [NSBundle bundleWithPath:bundlestring];
|
|
395
|
UIImage *successImg = [UIImage imageNamed:@"fail" inBundle:bundle compatibleWithTraitCollection:nil];
|
|
396
|
|
|
397
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 95)];
|
|
398
|
view.layer.cornerRadius = 5;
|
|
399
|
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, view.width, view.height)];
|
|
400
|
imgView.layer.cornerRadius = 5;
|
|
401
|
imgView.image = successImg;
|
|
402
|
[view addSubview:imgView];
|
|
403
|
|
|
404
|
[self showHUDWithImageView:view DisplayTime:time];
|
|
405
|
}
|
|
406
|
|
|
407
|
#pragma mark - ios method
|
|
408
|
/*
|
56
|
409
|
内部IOS访问:显示一个带文字的提示框,持续指定时长后隐藏
|
57
|
410
|
*/
|
58
|
411
|
-(void)showHUDWithText:(NSString *)txt DisplayTime:(NSTimeInterval)time{
|
59
|
412
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
60
|
|
if (vc.ipuHud==nil) {
|
61
|
|
IPUProgressHUD *hud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
62
|
|
[vc.view addSubview:hud];
|
63
|
|
}
|
|
413
|
vc.ipuHud = nil;
|
|
414
|
vc.ipuHud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
|
415
|
[vc.view addSubview:vc.ipuHud];
|
64
|
416
|
vc.ipuHud.mode = IPUProgressHUDModeText;
|
65
|
417
|
vc.ipuHud.margin = 12.f;
|
66
|
418
|
vc.ipuHud.labelText = txt;
|
|
@ -68,4 +420,57 @@
|
68
|
420
|
[vc.ipuHud hide:YES afterDelay:time];//延迟time时长后隐藏
|
69
|
421
|
}
|
70
|
422
|
|
|
423
|
/*
|
|
424
|
内部IOS访问:显示一个自定义视图
|
|
425
|
*/
|
|
426
|
-(void)showHUDWithCustomView:(UIView *)view{
|
|
427
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
|
428
|
vc.ipuHud = nil;
|
|
429
|
vc.ipuHud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
|
430
|
[vc.view addSubview:vc.ipuHud];
|
|
431
|
vc.ipuHud.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
|
432
|
vc.ipuHud.color = [UIColor whiteColor];
|
|
433
|
vc.ipuHud.mode = IPUProgressHUDModeCustomView;
|
|
434
|
vc.ipuHud.customView = view;
|
|
435
|
[vc.ipuHud show:YES];//显示hud
|
|
436
|
}
|
|
437
|
|
|
438
|
/*
|
|
439
|
内部IOS访问:显示一个自定义视图
|
|
440
|
*/
|
|
441
|
-(void)showHUDWithImageView:(UIView *)view DisplayTime:(NSTimeInterval)time{
|
|
442
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
|
443
|
vc.ipuHud = nil;
|
|
444
|
vc.ipuHud = [[IPUProgressHUD alloc] initWithView:vc.view];
|
|
445
|
[vc.view addSubview:vc.ipuHud];
|
|
446
|
vc.ipuHud.mode = IPUProgressHUDModeCustomView;
|
|
447
|
vc.ipuHud.customView = view;
|
|
448
|
[vc.ipuHud show:YES];//显示hud
|
|
449
|
[vc.ipuHud hide:YES afterDelay:time];//延迟time时长后隐藏
|
|
450
|
}
|
|
451
|
|
|
452
|
#pragma mark - click action
|
|
453
|
-(void)cancelAction:(UIButton *)sender{
|
|
454
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
|
455
|
if (vc.ipuHud) {
|
|
456
|
[vc.ipuHud hide:YES];
|
|
457
|
}
|
|
458
|
}
|
|
459
|
|
|
460
|
-(void)okAction:(UIButton *)sender{
|
|
461
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
|
462
|
if (vc.ipuHud) {
|
|
463
|
[vc.ipuHud hide:YES];
|
|
464
|
}
|
|
465
|
[super callback:@"1"];
|
|
466
|
}
|
|
467
|
|
|
468
|
-(void)submitAction:(UIButton *)sender{
|
|
469
|
WDViewController *vc = (WDViewController *)[self getViewController];
|
|
470
|
if (vc.ipuHud) {
|
|
471
|
[vc.ipuHud hide:YES];
|
|
472
|
}
|
|
473
|
[super callback:inputField.text];
|
|
474
|
}
|
|
475
|
|
71
|
476
|
@end
|