JLChen
2021-04-30 a5247b61d585627a1a7b1e1f35f34de9f0af9fba
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
//
//  Copyright © 2018 Jimmy. All rights reserved.
//
//  封装UIAlertController,使用扩展的话太奇怪了
 
#import <UIKit/UIKit.h>
 
@class LCAlertController;
/// index为0表示取消,index为1表示其他按钮
typedef void(^LCAlertControllerHandler)(NSInteger index);
 
@interface LCAlertController : UIAlertController
 
/**
 弹出框
 
 @param title 标题
 @param message 内容
 @param cancelButtonTitle 取消按钮
 @param otherButtonTitle 确定按钮
 @param handler 点击回调
 */
+ (LCAlertController *)showWithTitle:(NSString *)title
                             message:(NSString *)message
                   cancelButtonTitle:(NSString *)cancelButtonTitle
                    otherButtonTitle:(NSString *)otherButtonTitle
                             handler:(LCAlertControllerHandler)handler;
/**
 弹出警告框
 
 @param title 标题
 @param message 内容
 @param cancelButtonTitle 取消按钮
 @param otherButtonTitles 其它按钮数组
 @param handler handler
 
 注意: 该方法不能在已经是 present 出来的控制器中弹出警告框,请使用另外一个带控制器参数的方法弹出
 */
+ (LCAlertController *)showWithTitle:(NSString *)title
                             message:(NSString *)message
                   cancelButtonTitle:(NSString *)cancelButtonTitle
                   otherButtonTitles:(NSArray<NSString *> *)otherButtonTitles
                             handler:(LCAlertControllerHandler)handler;
 
/**
 弹出框
 
 @param vc 需要显示在哪个控制器
 @param title 标题
 @param message 内容
 @param cancelButtonTitle 取消按钮
 @param otherButtonTitle 确定按钮
 @param handler 点击回调
 */
+ (LCAlertController *)showInViewController:(UIViewController *)vc
                                      title:(NSString *)title
                                    message:(NSString *)message
                          cancelButtonTitle:(NSString *)cancelButtonTitle
                           otherButtonTitle:(NSString *)otherButtonTitle
                                    handler:(LCAlertControllerHandler)handler;
 
/**
 根据指定vc弹出警告框
 
 @param vc 对应控制器
 @param title 标题
 @param message 内容
 @param cancelButtonTitle 取消按钮
 @param otherButtonTitles 其它按钮数组
 @param handler handler
 */
 
+ (LCAlertController *)showInViewController:(UIViewController *)vc
                                      title:(NSString *)title
                                    message:(NSString *)message
                          cancelButtonTitle:(NSString *)cancelButtonTitle
                          otherButtonTitles:(NSArray<NSString *> *)otherButtonTitles
                                    handler:(LCAlertControllerHandler)handler;
 
/**
 隐藏弹出框
 
 @param isAnimated 是否动画
 */
+ (void)dismissAnimated:(BOOL)isAnimated;
 
/**
 隐藏弹出框,无动画
 */
+ (void)dismiss;
 
/**
 显示中
 */
+ (BOOL)isDisplayed;
 
/**
 找到最上层的弹出框,非UIAlertController
 
 @return UIViewController
 */
+ (UIViewController *)topPresentOrRootController;
 
@end