AlertViewTool.m
4.24 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
//
// AlertViewTool.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/20.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "AlertViewTool.h"
@implementation AlertViewTool
+ (void)showHUDAddedToView:(UIView *)view duration:(NSInteger)duration{
[MBProgressHUD showHUDAddedTo:view animated:YES];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do something...
[MBProgressHUD hideHUDForView:view animated:YES];
});
}
+ (void)showHUDAddedToView:(UIView *)view text:(NSString *)text duration:(NSInteger)duration{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text = text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do something...
[hud hideAnimated:YES];
});
}
+ (void)showHUDAddedToView:(UIView *)view text:(NSString *)text{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text = text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do something...
[hud hideAnimated:YES];
});
}
+ (void)showHUDAddedToView:(UIView *)view text:(NSString *)text block:(PopBlock)block{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text = text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do something...
[hud hideAnimated:YES];
block?block():@"";
});
}
+ (void)showHUDViewText:(NSString *)text{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self getCurrentVC].view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text =text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do something...
[hud hideAnimated:YES];
});
}
+ (void)showHUDViewText:(NSString *)text block:(PopBlock)block{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self getCurrentVC].view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text = text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[hud hideAnimated:YES];
block?block():@"";
});
}
+ (void)showHUDViewText:(NSString *)text block:(PopBlock)block duration:(NSInteger)duration{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[self getCurrentVC].view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.label.text = text;
hud.label.numberOfLines = 0;
hud.label.lineBreakMode = NSLineBreakByCharWrapping;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[hud hideAnimated:YES];
block?block():@"";
});
}
+ (void)showHUDView{
[MBProgressHUD showHUDAddedTo:[self getCurrentVC].view animated:YES];
}
+ (void)hideHUDView{
[MBProgressHUD hideHUDForView:[self getCurrentVC].view animated:YES];
}
+ (UIViewController *)getCurrentVC{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
@end