UIAlertController类--alert弹框2(Destructive “警示”)

一、效果

计算机生成了可选文字:
标 题 
这 个 是 UlAlertContr011er 的 默 认 样 式 
取 消 
重 置

 

二、实现

 

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

{

    [self alertTest2];

}

 

/**

 *  Destructive :“警示”样式

 */

- (void)alertTest2

{

    //1.创建UIAlertController

    UIAlertController *alertController = [UIAlertController

                                          alertControllerWithTitle:@"标题"

                                          message:@"这个是UIAlertController的默认样式"

                                          preferredStyle:UIAlertControllerStyleAlert];

    //2.创建UIAlertAction实例

    

    /**

     “警示”样式的按钮:红色按钮,用在可能会改变或删除数据的操作上

     */

    UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:@"重置" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {

        

    }];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

        

    }];

    

    //3.UIAlertAction实例添加到UIAlertController

    [alertController addAction:destructiveAction];

    [alertController addAction:cancelAction];

    

    //4.显示对话框视图控制器

    [self presentViewController:alertController animated:YES completion:^{

        

    }];

    

}

posted @ 2015-11-18 09:23  我就叫M  阅读(419)  评论(0编辑  收藏  举报