标签:
一、效果
二、实现
- (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:^{
}];
}
UIAlertController类--alert弹框2(Destructive “警示”)
标签:
原文地址:http://www.cnblogs.com/M-Y-P/p/4972541.html