废话不多说,直接上代码,效果是最好的说服力

1、改变UIAlertView字体颜色

[UIView appearance].tintColor = [UIColor greenColor];

个人还是比较喜欢使用UIAlertView,简单粗暴达到想要的效果

2、改变UIActionSheet字体颜色

// 改变 actionSheet字体颜色

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {

SEL selector = NSSelectorFromString(@"_alertController");

if ([actionSheet respondsToSelector:selector])//ios8

{

UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];

if ([alertController isKindOfClass:[UIAlertController class]]) {

alertController.view.tintColor = [UIColor greenColor];

}

//ios7

} else{

for( UIView * subView in actionSheet.subviews ) {

if( [subView isKindOfClass:[UIButton class]] ) {

UIButton * btn = (UIButton*)subView;

[btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];

}

}

}

}

3、改变UIAlertController字体颜色

- (void)buttonClick:(UIButton *)sender {

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"提示内容" preferredStyle:UIAlertControllerStyleAlert];

//修改标题的内容,字号,颜色。使用的key值是“attributedTitle”

NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"heihei"];

[hogan addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:50] range:NSMakeRange(0, [[hogan string] length])];

[hogan addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, [[hogan string] length])];

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

//修改按钮的颜色,同上可以使用同样的方法修改内容,样式

UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Default" style:UIAlertActionStyleDefault handler:nil];

[defaultAction setValue:[UIColor blueColor] forKey:@"_titleTextColor"];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];

[cancelAction setValue:[UIColor greenColor] forKey:@"_titleTextColor"];

[alertController addAction:defaultAction];

[alertController addAction:cancelAction];

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

}

最新文章

  1. struts2.5的配置及其注意事项
  2. Redis复制与可扩展集群搭建
  3. 怎样学习Scala泛函编程
  4. NSNotification Name 最佳写法
  5. 必须正确理解的---ng指令中的compile与link函数解析
  6. 未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序。
  7. zend
  8. centos6.4 挂载ntfs分区
  9. Codeforces Gym 100114 A. Hanoi tower 找规律
  10. decodeURIComponent
  11. IOS详解TableView——选项抽屉(天猫商品列表)
  12. handsontable插件HOOK事件
  13. git创建分支
  14. spring boot无法启动,或者正常启动之后无法访问报404的解决办法
  15. struts2(三)之表单参数自动封装与参数类型自动转换
  16. Pivotal开源基于PostgreSQL的数据库Greenplum
  17. hyperopt自动调参
  18. 几个js框架
  19. @Pointcut的用法
  20. mysql与redis在各种情况下性能对比

热门文章

  1. HDU 1033 Edge[地图型模拟/给你一串字符串,A代表以此点为参照顺时针90°,V代表逆时针90°]
  2. React 入门之路
  3. [转] 使用SVN进行源码管理
  4. IOS7开发~API变化
  5. cocos2dx 2.x新建项目
  6. LeetCode Recover Binary Search Tree——二查搜索树中两个节点错误
  7. HBase笔记
  8. js:string转int
  9. zabbix agent shell一键安装脚本
  10. JSP简单练习-用Servlet获取表单数据