您的位置:首页 > 产品设计 > UI/UE

1.UIAlertController

2016-05-17 14:36 411 查看
UIAlertController
效果

1.UIAlertController

//初始化
//preferredStyle:UIAlertControllerStyleAlert:      中间显示警告框
//               UIAlertControllerStyleActionSheet:底边显示警告框
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message: @"内容" preferredStyle: UIAlertControllerStyleAlert];

//创建按钮
//style:UIAlertActionStyleCancel:      取消按钮
//      UIAlertActionStyleDefault:     默认显示按钮
//      UIAlertActionStyleDestructive: 红色显示按钮
UIAlertAction *alerButton = [UIAlertAction actionWithTitle: @"按钮内容" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//点击按钮后进行的操作
}];

//创建文本输入框
[aler addTextFieldWithConfigurationHandler:^(UITextField *textField){
//操作内容
}];

//添加UIAlertAction至UIAlertController
//顺序就是呈现的上下顺序(取消按钮自动处于最下面或最左边)
[alert addAction: alerButton];

//呈现警告视图
[self presentViewController: alert animated:YES completion:nil];


源码:https://yunpan.cn/cSdVKavV8RqFT (提取码:1e6f)

效果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: