UIAlertController

 1  UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"警告" message:@"测试1" preferredStyle:UIAlertControllerStyleActionSheet ];
 2     // 设置popover指向的item
 3     alert.popoverPresentationController.barButtonItem = self.navigationItem.leftBarButtonItem;
 4     
 5     // 添加按钮
 6     [alert addAction:[UIAlertAction actionWithTitle:@"修改" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
 7         NSLog(@"点击了修改按钮");
 8     }]];
 9     [alert addAction:[UIAlertAction actionWithTitle:@"编辑" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
10         NSLog(@"点击了编辑按钮");
11     }]];
12     [alert addAction:[UIAlertAction actionWithTitle:@"打印" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
13         NSLog(@"点击了打印按钮");
14     }]];
15     [alert addAction:[UIAlertAction actionWithTitle:@"作废" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
16         NSLog(@"点击了作废按钮");
17     }]];
18     [alert addAction:[UIAlertAction actionWithTitle:@"取消编辑" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
19         NSLog(@"点击了取消编辑按钮");
20     }]];
21     
22     [alert addAction:[UIAlertAction actionWithTitle:@"取消检查" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
23         NSLog(@"点击了取消检查按钮");
24     }]];
25     [alert addAction:[UIAlertAction actionWithTitle:@"回到上一步" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
26         NSLog(@"点击了回到上一步按钮");
27     }]];
28 
29     [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
30         NSLog(@"点击了取消按钮");
31     }]];
32 
33     [self presentViewController:alert animated:YES completion:nil];
34     
View Code

 

样式:

UIAlertActionStyleDefault:蓝色

UIAlertActionStyleCancel:取消会有一段距离

UIAlertActionStyleDestructive :红色

 

posted @ 2017-12-28 10:52  懒猫口米  阅读(119)  评论(0编辑  收藏  举报