Skip to content

Commit 0474db2

Browse files
author
MrChen
authored
Update EasyAlert_README.md
1 parent 7594d78 commit 0474db2

File tree

1 file changed

+51
-48
lines changed

1 file changed

+51
-48
lines changed

README/EasyAlert_README.md

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## EasyText使用方法
1+
## EasyAlert使用方法
22

33
#### 在AppDelegate中设置全局的配置信息 -- (可省略)
44

@@ -7,84 +7,87 @@
77
88
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
99
{
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];
1413
}
1514
```
1615

1716
#### 调用显示方法 --(如果单独某个显示视图不想用全局的配置信息,可以在每个显示方法中的config配置)
1817

1918
```
19+
2020
/**
21-
* 显示一个纯文字消息 (config:显示属性设置)
21+
* 快速创建AlertView的方法
22+
*
23+
* part alertView的组成部分 标题,副标题,显示类型
24+
* config 配置信息(如果为空,就是使用EasyAlertGlobalConfig中的属性值)
25+
* buttonArray 所以需要显示的按钮
26+
* callback 点击按钮回调
2227
*/
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+
2533
```
2634

2735

2836
```
2937
/**
30-
* 显示一个成功消息(config:显示属性设置)
38+
* 第一步:创建一个自定义的Alert/ActionSheet
3139
*/
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 ;
3444
35-
```
45+
+ (instancetype)alertViewWithPart:(EasyAlertPart *(^)(void))part
46+
config:(EasyAlertConfig *(^)(void))config
47+
callback:(AlertCallback)callback ;
3648
37-
```
3849
/**
39-
* 显示一个错误消息(config:显示属性设置)
50+
* 第二步:往创建的alert上面添加事件
4051
*/
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 ;
4358
44-
```
45-
46-
```
4759
/**
48-
* 显示一个提示消息(config:显示属性设置)
60+
* 第三步:展示alert
4961
*/
50-
+ (void)showInfoText:(NSString *)text ;
51-
+ (void)showInfoText:(NSString *)text config:(EasyTextConfig *(^)(void))config ;
52-
62+
- (void)showAlertView ;
5363
```
5464

5565
```
56-
/**
57-
* 显示一个自定义图片消息(config:显示属性设置)
58-
*/
59-
+ (void)showImageText:(NSString *)text imageName:(NSString *)imageName ;
60-
+ (void)showImageText:(NSString *)text imageName:(NSString *)imageName config:(EasyTextConfig *(^)(void))config ;
6166
62-
```
67+
// 移除alertview
68+
- (void)removeAlertView ;
6369
64-
#### 举例说明
6570
```
66-
//没有加配置信息,所以显示的样式都会使用appdelegate中EasyTextGlobalConfig设置的。
67-
[EasyTextView showSuccessText:@"显示成功消息!"];
6871

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+
}];
7383
7484
```
75-
#### EasyTextConfig说明:它是显示属性的配置信息。提供了三种方法。这三种方法都是一样的,根据使用习惯选择一种就行。
85+
#### EasyAlertPart:它是显示属性的配置信息。提供了三种方法。这三种方法都是一样的,根据使用习惯选择一种就行。
7686
```
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种
8891
```
8992

9093

0 commit comments

Comments
 (0)