//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];