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

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

}

iOS改变UIAlertView、UIActionSheet、UIAlertController系统字体颜色的更多相关文章

  1. iOS开发之iOS7设置状态栏字体颜色

    应用中登陆界面颜色较浅,状态栏字体颜色为黑色,跳转到主界面之后,界面颜色较深,状态栏颜色随之变成白色.但是再重新返回登陆界面后,状态栏字体颜色并没有改成黑色,特别别扭. plist文件里将View c ...

  2. ios修改textField的placeholder的字体颜色和大小

    textField.placeholder = @"username is in here!"; [textField setValue:[UIColor redColor] fo ...

  3. ios修改textField的placeholder的字体颜色、大小

    textField.placeholder = @"username is in here!"; [textField setValue:[UIColor redColor] fo ...

  4. ios 更改UITableview中Section的字体颜色

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *c ...

  5. 改变label中的某字体颜色

    NSString *allString=@"你家在哪里,需要我送你么"; NSString *subString=@"在哪里"; UILabel *string ...

  6. H5表单中placeholder属性的字体颜色问题

    最近做项目的时候遇到的一些小样式问题,有关表单.并且在接下来几天的面试人中五个人都没有回答上来,改变placeholder属性的默认字体颜色,感觉有必要总结一下. 如何改变默认字体的颜色? @blue ...

  7. js点击按钮为元素随机字体颜色和背景色

    文章地址 https://www.cnblogs.com/sandraryan/ 写两个button和一个div,点击按钮分别改变背景色和前景色(字体颜色).产生的是一个随机颜色. <!DOCT ...

  8. IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容

    IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容 UIAlertController *alertVC = [UIAlertController alertControl ...

  9. 【iOS学习笔记】改变状态栏字体颜色

    Step1. info.plist中设置UIViewControllerBasedStatusBarAppearance为NO Step2. AppDelegate.m中添加 - (BOOL)appl ...

随机推荐

  1. 提升开发效率的一款mybatis开发神器

    文末附有完整案例的代码内容!! 以前在开发的时候,使用mybatis的时候,经常都需要先配置xml映射文件,然后每条sql操作都需要自己进行手动编写,对于一些复杂的sql这么来操作确实有必要,但是如果 ...

  2. POJ 1155 TELE [树状DP]

    题意:略. 思路:用dp[i][k]来表示结点i给k个用户提供节目时的最大盈利(可能为负). 则递推方程为: dp[i][j] = max(dp[i][j], dp[i][m] + dp[v][j-m ...

  3. JDBC-oracle(登陆)

    题目: 第一步:创建用户表,并插入数据(插入后记得commit) create table users ( name ), password ) ); '); '); 第二步:编写登陆界面(index ...

  4. iOS 定位坐标不准确的相关整理及解决方案汇总

    这几天处理定位相关的代码,彻彻底底的被火星坐标恶心到了. 恶心列表 从 CLLocationManager 取出来的经纬度放到 mapView 上显示,是错的! 从 CLLocationManager ...

  5. AIX 删除指定目录、指定后缀、指定天数以前的历史文件

    find /home/oracle/admin/zhjport/udump/ -name "*.trc" -mtime +30 -exec rm {} \; 如果要自动执行可以加入 ...

  6. Linux下监听或绑定(bind)21端口失败

    问题:写了一个程序,尝试在21端口监听,结果在执行bind的时候失败了. sockaddr_in sock_addr; sock_addr.sin_family = AF_INET; sock_add ...

  7. 【重点突破】—— Vue1.0到Vue2.0的变化

    前言: 本文参考作者:_So_ 和 我是某慧 的博文,重点梳理Vue1.0升级到Vue2.0后在开发中要注意的不同,以做学习.        组件模板不再支持片段代码,必须有一个顶级元素包裹,例如: ...

  8. 转: 为什么做java的web开发我们会使用struts2,springMVC和spring这样的框架?

    from: https://github.com/RubyLouvre/agate/issues/8 今年我一直在思考web开发里的前后端分离的问题,到了现在也颇有点心得了,随着这个问题的深入,再加以 ...

  9. JSON之—— JSON.parse()和JSON.stringify() (插曲)

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46391269 parse用于从一个字符串中解析出json对象,如 var str ...

  10. UNP学习笔记(第六章 I/O复用)

    I/O模型 首先我们将查看UNIX下可用的5种I/O模型的基本区别: 1.阻塞式I/O 2.非阻塞式I/O 3.I/O复用(select和poll) 4.信号驱动式I/O(SIGIO) 5.异步I/O ...