警告框

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDestructive handler:nil];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

[alertController addAction:destructiveAction];
[alertController addAction:cancelAction];

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

//修改title
NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"提示"];
[alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
[alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
[alertController setValue:alertControllerStr forKey:@"attributedTitle"];

//修改message
NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:@"提示内容"];
[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 4)];
[alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 4)];
[alertController setValue:alertControllerMessageStr forKey:@"attributedMessage"];

作者:PlutoMa
链接:http://www.jianshu.com/p/51949eec2e9c
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 字体属性设置示例:if(color ==nil) {color = [NSColor redColor];}NSF...
    袏扌戒指阅读 12,636评论 0 2
  • 与NSString类似,在iOS中AttributedString也分为NSAttributedString和 N...
    钱十六阅读 4,223评论 0 0
  • 转载:http://blog.csdn.net/u010330109/article/details/518821...
    F麦子阅读 9,643评论 0 3
  • 凌晨有雨 我咖啡杯 摔坏了 家里也没有其他杯 接雨。
    留子尧阅读 1,378评论 2 2
  • 一、androidannotations 依赖注入(Dependency injection): 支持view, ...
    _Justin阅读 3,570评论 0 0