|
1 |
| -## EasyText使用方法 |
| 1 | +## EasyAlert使用方法 |
2 | 2 |
|
3 | 3 | #### 在AppDelegate中设置全局的配置信息 -- (可省略)
|
4 | 4 |
|
|
7 | 7 |
|
8 | 8 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
9 | 9 | {
|
10 |
| - /**显示文字**/ |
11 |
| - EasyTextGlobalConfig *config = [EasyTextGlobalConfig shared]; |
12 |
| - config.bgColor = [UIColor whiteColor]; |
13 |
| - config.titleColor = [UIColor blackColor]; |
| 10 | + /**显示alert**/ |
| 11 | + EasyAlertGlobalConfig *alertConfig = [EasyAlertGlobalConfig shared]; |
| 12 | + alertConfig.titleColor = [UIColor blackColor]; |
14 | 13 | }
|
15 | 14 | ```
|
16 | 15 |
|
17 | 16 | #### 调用显示方法 --(如果单独某个显示视图不想用全局的配置信息,可以在每个显示方法中的config配置)
|
18 | 17 |
|
19 | 18 | ```
|
| 19 | +
|
20 | 20 | /**
|
21 |
| - * 显示一个纯文字消息 (config:显示属性设置) |
| 21 | + * 快速创建AlertView的方法 |
| 22 | + * |
| 23 | + * part alertView的组成部分 标题,副标题,显示类型 |
| 24 | + * config 配置信息(如果为空,就是使用EasyAlertGlobalConfig中的属性值) |
| 25 | + * buttonArray 所以需要显示的按钮 |
| 26 | + * callback 点击按钮回调 |
22 | 27 | */
|
23 |
| -+ (void)showText:(NSString *)text ; |
24 |
| -+ (void)showText:(NSString *)text config:(EasyTextConfig *(^)(void))config ; |
| 28 | ++ (EasyAlertView *)alertViewWithPart:(EasyAlertPart *(^)(void))part |
| 29 | + config:(EasyAlertConfig *(^)(void))config |
| 30 | + buttonArray:(NSArray<NSString *> *(^)(void))buttonArray |
| 31 | + callback:(AlertCallback)callback ; |
| 32 | +
|
25 | 33 | ```
|
26 | 34 |
|
27 | 35 |
|
28 | 36 | ```
|
29 | 37 | /**
|
30 |
| - * 显示一个成功消息(config:显示属性设置) |
| 38 | + * 第一步:创建一个自定义的Alert/ActionSheet |
31 | 39 | */
|
32 |
| -+ (void)showSuccessText:(NSString *)text ; |
33 |
| -+ (void)showSuccessText:(NSString *)text config:(EasyTextConfig *(^)(void))config ; |
| 40 | ++ (instancetype)alertViewWithTitle:(NSString *)title |
| 41 | + subtitle:(NSString *)subtitle |
| 42 | + AlertViewType:(AlertViewType)alertType |
| 43 | + config:(EasyAlertConfig *(^)(void))config ; |
34 | 44 |
|
35 |
| -``` |
| 45 | ++ (instancetype)alertViewWithPart:(EasyAlertPart *(^)(void))part |
| 46 | + config:(EasyAlertConfig *(^)(void))config |
| 47 | + callback:(AlertCallback)callback ; |
36 | 48 |
|
37 |
| -``` |
38 | 49 | /**
|
39 |
| - * 显示一个错误消息(config:显示属性设置) |
| 50 | + * 第二步:往创建的alert上面添加事件 |
40 | 51 | */
|
41 |
| -+ (void)showErrorText:(NSString *)text ; |
42 |
| -+ (void)showErrorText:(NSString *)text config:(EasyTextConfig *(^)(void))config ; |
| 52 | +- (void)addAlertItemWithTitle:(NSString *)title |
| 53 | + type:(AlertItemType)type |
| 54 | + callback:(AlertCallback)callback; |
| 55 | +- (void)addAlertItem:(EasyAlertItem *(^)(void))item ; |
| 56 | +- (void)addAlertItemWithTitleArray:(NSArray *)titleArray |
| 57 | + callback:(AlertCallback)callbck ; |
43 | 58 |
|
44 |
| -``` |
45 |
| - |
46 |
| -``` |
47 | 59 | /**
|
48 |
| - * 显示一个提示消息(config:显示属性设置) |
| 60 | + * 第三步:展示alert |
49 | 61 | */
|
50 |
| -+ (void)showInfoText:(NSString *)text ; |
51 |
| -+ (void)showInfoText:(NSString *)text config:(EasyTextConfig *(^)(void))config ; |
52 |
| -
|
| 62 | +- (void)showAlertView ; |
53 | 63 | ```
|
54 | 64 |
|
55 | 65 | ```
|
56 |
| -/** |
57 |
| - * 显示一个自定义图片消息(config:显示属性设置) |
58 |
| - */ |
59 |
| -+ (void)showImageText:(NSString *)text imageName:(NSString *)imageName ; |
60 |
| -+ (void)showImageText:(NSString *)text imageName:(NSString *)imageName config:(EasyTextConfig *(^)(void))config ; |
61 | 66 |
|
62 |
| -``` |
| 67 | +// 移除alertview |
| 68 | +- (void)removeAlertView ; |
63 | 69 |
|
64 |
| -#### 举例说明 |
65 | 70 | ```
|
66 |
| -//没有加配置信息,所以显示的样式都会使用appdelegate中EasyTextGlobalConfig设置的。 |
67 |
| -[EasyTextView showSuccessText:@"显示成功消息!"]; |
68 | 71 |
|
69 |
| -//增加config配置信息。那么statusType属性会使用刚设置的。其他属性会继续使用EasyTextGlobalConfig设置的。 |
70 |
| -[EasyTextView showErrorText:@"服务器错误!" config:^EasyTextConfig *{ |
71 |
| - return [EasyTextConfig shared].setStatusType(TextStatusTypeNavigation) ; |
72 |
| -}]; |
| 72 | +#### 举例说明 -- 请参考demo |
| 73 | +``` |
| 74 | + [EasyAlertView alertViewWithPart:^EasyAlertPart *{ |
| 75 | + return [EasyAlertPart shared].setTitle(@"请点击两下").setSubtitle(@"1,点击背景是否接受事件\n2,改变动画类型。\n3,只有两个按钮的时候,是横排还是竖排.\n4,改变背景颜色").setAlertType(AlertViewTypeAlert) ; |
| 76 | + } config:^EasyAlertConfig *{ |
| 77 | + return [EasyAlertConfig shared].settwoItemHorizontal(hovizonal).setAnimationType(aniType).setTintColor(tintC).setBgViewEvent(NO).setSubtitleTextAligment(NSTextAlignmentLeft) ; |
| 78 | + } buttonArray:^NSArray<NSString *> *{ |
| 79 | + return @[@"确定",@"取消"] ; |
| 80 | + } callback:^(EasyAlertView *showview , long index) { |
| 81 | + index ? [EasyTextView showSuccessText:@"点击了取消"] : [EasyTextView showText:@"点击了确定"]; |
| 82 | + }]; |
73 | 83 |
|
74 | 84 | ```
|
75 |
| - #### EasyTextConfig说明:它是显示属性的配置信息。提供了三种方法。这三种方法都是一样的,根据使用习惯选择一种就行。 |
| 85 | + #### EasyAlertPart:它是显示属性的配置信息。提供了三种方法。这三种方法都是一样的,根据使用习惯选择一种就行。 |
76 | 86 | ```
|
77 |
| - //方法一 |
78 |
| - return [EasyTextConfig configWithSuperView:self.view superReceiveEvent:ShowTextEventUndefine animationType:TextAnimationTypeNone textStatusType:TextStatusTypeBottom]; |
79 |
| - //方法二 |
80 |
| - return [EasyTextConfig shared].setBgColor([UIColor lightGrayColor]).setShadowColor([UIColor clearColor]).setStatusType(TextStatusTypeBottom); |
81 |
| - //方法三 |
82 |
| - EasyTextConfig *config = [EasyTextConfig shared]; |
83 |
| - config.bgColor = [UIColor lightGrayColor] ; |
84 |
| - config.shadowColor = [UIColor clearColor] ; |
85 |
| - config.animationType = TextAnimationTypeFade; |
86 |
| - config.statusType = TextStatusTypeBottom ; |
87 |
| - return config ; |
| 87 | +
|
| 88 | +@property (nonatomic,strong)NSString *title ; //标题 |
| 89 | +@property (nonatomic,strong)NSString *subtitle ; //副标题 |
| 90 | +@property (nonatomic,assign)AlertViewType alertType ; //alert类型 分4种 |
88 | 91 | ```
|
89 | 92 |
|
90 | 93 |
|
|
0 commit comments