博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS9的警告框
阅读量:7071 次
发布时间:2019-06-28

本文共 2012 字,大约阅读时间需要 6 分钟。

hot3.png

//IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)

//http://www.ithao123.cn/content-9409772.html

NSString *message = @"确认清除所有缓存?";

// NSString *message = @"您确定要拨打010-334-4432";

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:(UIAlertControllerStyleAlert)];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确认清除" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {

// 点击确定按钮后的方法直接在这里面写

NSLog(@"333");

}];

UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {

//点击取消按钮后的方法直接在这里面写

NSLog(@"222");

}];

//修改title

NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"确认"];

[alertControllerStr addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x000000) range:NSMakeRange(0, 2)];

[alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, 2)];

[alertController setValue:alertControllerStr forKey:@"attributedTitle"];

//修改message

NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:message];

[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xF12A42) range:NSMakeRange(0, 18)];

[alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, 18)];

[alertController setValue:alertControllerMessageStr forKey:@"attributedMessage"];

[cancleAction setValue:UIColorFromRGB(0x4990E2) forKey:@"titleTextColor"];

[okAction setValue:UIColorFromRGB(0xF12A42) forKey:@"titleTextColor"];

 

// 添加按钮 将按钮添加到UIAlertController对象上

[alertController addAction:cancleAction];

[alertController addAction:okAction];

// 将UIAlertController模态出来 相当于UIAlertView show 的方法

[self presentViewController:alertController animated:YES completion:nil];

转载于:https://my.oschina.net/huangyn/blog/800254

你可能感兴趣的文章
Spring 中JDKProxy和CGlibProxy的区别
查看>>
在Map 3D显示管理器中更改当前地图的名字
查看>>
通俗解释WIndows上的CRITICAL SECTION
查看>>
下载文件使用缓存(一次性读取到内存),优化性能(注意静态对象修改需要加锁)...
查看>>
组织行为学对项目管理的意义(2):人格的大五模型
查看>>
NGUI Sprite Type(Simple、Sliced、Tiled、Filed、Advanced)
查看>>
Windows Phone开发(12):认识一下独具个性的磁贴
查看>>
每日英语:Six Ways to Modernize Your Car
查看>>
使用VS2010开发Qt程序的一点经验
查看>>
tpl demo
查看>>
用Ghostscript API将PDF格式转换为图像格式(C#)
查看>>
Android自定义进度条
查看>>
编写高质量代码改善C#程序的157个建议[匿名类型、Lambda、延迟求值和主动求值]...
查看>>
CkEditor 插件开发
查看>>
《如何让TT T4模板输出多个文件(VS2010中)》-- access911.net 文章
查看>>
CSS Hack大全-可区分出IE6-IE10、FireFox、Chrome、Opera
查看>>
从程序员到项目经理(16):原来一切问题都是可以解决的【转载】
查看>>
当kfreebsd 用户遇见openSUSE系统
查看>>
Struts2自己定义拦截器实例—登陆权限验证
查看>>
调用webservice查询手机号码归属地信息
查看>>