11
11
#import " UIImage+ImageEffects.h"
12
12
13
13
@interface ViewController ()
14
-
15
14
@end
16
15
17
16
@implementation ViewController
@@ -56,18 +55,18 @@ - (IBAction)showActionSheetAction:(id)sender {
56
55
TYAlertView *alertView = [TYAlertView alertViewWithTitle: @" TYAlertView" message: @" A message should be a short, complete sentence." ];
57
56
58
57
[alertView addAction: [TYAlertAction actionWithTitle: @" 默认2" style: TYAlertActionStyleDefault handler: ^(TYAlertAction *action) {
59
-
58
+ NSLog ( @" %@ " ,action. title );
60
59
}]];
61
60
62
61
[alertView addAction: [TYAlertAction actionWithTitle: @" 默认1" style: TYAlertActionStyleDefault handler: ^(TYAlertAction *action) {
63
-
62
+ NSLog ( @" %@ " ,action. title );
64
63
}]];
65
64
66
65
[alertView addAction: [TYAlertAction actionWithTitle: @" 删除" style: TYAlertActionStyleDestructive handler: ^(TYAlertAction *action) {
67
-
66
+ NSLog ( @" %@ " ,action. title );
68
67
}]];
69
68
[alertView addAction: [TYAlertAction actionWithTitle: @" 取消" style: TYAlertActionStyleCancle handler: ^(TYAlertAction *action) {
70
-
69
+ NSLog ( @" %@ " ,action. title );
71
70
}]];
72
71
73
72
TYAlertController *alertController = [TYAlertController alertControllerWithAlertView: alertView preferredStyle: TYAlertControllerStyleActionSheet];
@@ -78,20 +77,37 @@ - (IBAction)blurEffectAlertViewAction:(id)sender {
78
77
TYAlertView *alertView = [TYAlertView alertViewWithTitle: @" TYAlertView" message: @" This is a blur effect on background, is beautiful effect" ];
79
78
80
79
[alertView addAction: [TYAlertAction actionWithTitle: @" 取消" style: TYAlertActionStyleCancle handler: ^(TYAlertAction *action) {
81
-
80
+ NSLog ( @" %@ " ,action. title );
82
81
}]];
83
82
84
83
TYAlertController *alertController = [TYAlertController alertControllerWithAlertView: alertView preferredStyle: TYAlertControllerStyleAlert];
85
84
86
- UIImage *blurImage =[[UIImage snapshotImageWithView: self .view] applyLightEffect ];
87
- UIImageView *blurImageView = [[UIImageView alloc ]initWithImage:blurImage];
88
- alertController.backgroundView = blurImageView;
85
+ // time consuming task ,so use dispatch_async .很耗时的操作
86
+ dispatch_async (dispatch_get_global_queue (0 , 0 ), ^{
87
+ // 处理耗时操作的代码块...
88
+ UIImage *blurImage =[[UIImage snapshotImageWithView: self .view] applyLightEffect ];
89
+ // 通知主线程刷新
90
+ dispatch_async (dispatch_get_main_queue (), ^{
91
+ UIImageView *blurImageView = [[UIImageView alloc ]initWithImage:blurImage];
92
+ alertController.backgroundView = blurImageView;
93
+ });
94
+
95
+ });
96
+
97
+ // UIImage *blurImage =[[UIImage snapshotImageWithView:self.view] applyLightEffect];
98
+ // UIImageView *blurImageView = [[UIImageView alloc]initWithImage:blurImage];
99
+ // alertController.backgroundView = blurImageView;
89
100
90
101
// alertController.alertViewOriginY = 60;
91
102
[self presentViewController: alertController animated: YES completion: nil ];
92
103
}
93
104
94
105
106
+ - (IBAction )costomAlertViewAction : (id )sender {
107
+
108
+ }
109
+
110
+
95
111
- (IBAction )showAlertViewInWindowAction : (id )sender {
96
112
97
113
// UIView *redView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
0 commit comments