NSString *message = @"请确认信息是否正确?";
NSString *title = @"提示";
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
//改变title的大小和颜色
NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc] initWithString:title];
[titleAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:] range:NSMakeRange(, title.length)];
[titleAtt addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(, title.length)];
[alertController setValue:titleAtt forKey:@"attributedTitle"];
//改变message的大小和颜色
NSMutableAttributedString *messageAtt = [[NSMutableAttributedString alloc] initWithString:message];
[messageAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:] range:NSMakeRange(, message.length)];
[messageAtt addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(, message.length)];
[alertController setValue:messageAtt forKey:@"attributedMessage"];
[self presentViewController:alertController animated:YES completion:nil];

上面的是修改UIAlertViewController的title和message字体的大小和颜色,采用的是修改attributedString其中的NSForegroundColorAttributeName颜色属性和NSFontAttributeName字体大小属性。UIAlertViewController中的标题的key:@"attributedTitle",标题中提示信息的key:@"attributedMessage"。

UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:nil];
[alertAction setValue:[UIColor purpleColor] forKey:@"_titleTextColor"];
// alertController.view.tintColor = [UIColor greenColor];
[alertController addAction:alertAction];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
/*取消按钮的颜色*/
[cancel setValue:[UIColor redColor] forKey:@"_titleTextColor"];
[alertController addAction:cancel];

修改UIAlertViewController中修改所有按钮的颜色使用下面这个方法:

alertController.view.tintColor = [UIColor greenColor];

修改单个UIAlertAction按钮的字体颜色使用下面这个方法:

[cancel setValue:[UIColor redColor] forKey:@"_titleTextColor"];

iOS之改变UIAlertViewController字体的颜色的更多相关文章

  1. UISegmentedControl 改变选中字体的颜色

    //设置选中的字体颜色为蓝色    [segmentControll setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor ...

  2. 改变placeholder字体的颜色

    /* Mozilla Firefox 19+ */ ::-moz-placeholder { color: #f00; } /* IE9+版本 */ input:-ms-input-placehold ...

  3. Lable 控件 -- 用代码改变要显示字体的颜色

    lable控件怎么改变显示字体的颜色 代码如下: string color = "#B72C34"; this.lbl.ForeColor = System.Drawing.Col ...

  4. pycharm 控制台字体背景颜色设定让你美到爆

    还在为你控制台字体颜色不入眼而发愁吗? 在某些特殊时刻想要改变下字体的颜色却无从下手而发愁吗? 那你就进来看一看,瞧一瞧,之需看2分钟,花2分钟理解,花3分钟练练手就能让你的控制能字体炫酷起来! 一. ...

  5. [iOS]改变UIAlertController的标题、内容的字体和颜色

    https://www.jianshu.com/p/51949eec2e9c 2016.03.23 22:36* 字数 272 阅读 37401评论 54喜欢 72 在开发中,弹出框是必不可少的,通常 ...

  6. Android(java)学习笔记96:如何改变spinner系统自带的字体和颜色

    1.首先我们要知道spinner系统自带字体和颜色本质: 原生的Spring 控件是无法更改字体和颜色的... 从下面的代码可以看出...红色的标注显示使用的是Android默认的布局.. Spinn ...

  7. WinForm开发中针对TreeView控件改变当前选择节点的字体与颜色

    本文转载:http://www.cnblogs.com/umplatform/archive/2012/08/29/2660240.html 在B/S开发中,对TreeView控件要改变当前选中节点的 ...

  8. Android(java)学习笔记35:如何改变Spinner系统自带的字体和颜色

    1. 首先我们要知道Spinner系统自带字体和颜色本质: 原生的Spring 控件是无法更改字体和颜色的... 从下面的代码可以看出...红色的标注显示使用的是Android默认的布局.. Spin ...

  9. 李洪强iOS开发之-修改状态栏的字体的颜色

    李洪强iOS开发之-修改状态栏的字体的颜色 修改的效果: -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [ ...

随机推荐

  1. BZOJ4773: 负环(倍增Floyd)

    题意 题目链接 Sol 倍增Floyd,妙妙喵 一个很显然的思路(然而我想不到是用\(f[k][i][j]\)表示从\(i\)号点出发,走\(k\)步到\(j\)的最小值 但是这样复杂度是\(O(n^ ...

  2. Redis学习笔记(二) ---- PHP操作Redis各数据类型

    Redis 一.使用PHP操作Redis存储系统中的各类数据类型方法 1.String(字符串)操作 <?php // 1. 实例化 $redis = new Redis; // 2. 连接 r ...

  3. Memcache 学习笔记(一)----Memcache — Linux部署

    Memcache 一.Memcache简介(内容摘自 --百度百科) memcache是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以 ...

  4. 30_AQS

    [参考文章] https://www.jianshu.com/p/df0d7d6571de http://ifeve.com/introduce-abstractqueuedsynchronizer/ ...

  5. 【Web crawler】simulated DFS web crawler

    Finish crawl web learned from udacity 提示:在某些时候,你必须在page上调用get_page.这似乎违反直觉,但是我们用 page 这个词时,指的网页的网址 ( ...

  6. Hush Framework框架配置(续) 转自《Android和PHP最佳实践》官方站

    图书资源下载 Xampp 开发环境下载:http://pan.baidu.com/share/link?shareid=531771&uk=773037279 微博实例完整源码包下载:http ...

  7. HBuilder自定义格式化代码

    对于代码格式到底为两个空格还是四个空格,可能大家喜欢的都不同,如果你是在使用HBuilder编辑器,那么恭喜你,这两种代码格式你可以轻易的更换.下面贴步骤 1.打开工具—>选项 2.选择HBui ...

  8. python 进程池的使用

    进程同步 进程的数据是独立存在的,进程也能加锁. from multiprocessing import Process, Lock def f(l,i): l.acquire() print('he ...

  9. Springmvc ajax跨域请求处理

    上次给一个网站写网站  前后端分离 最后跪在ajax跨域上面了  自己在网上找了个方法  亲试可用  记录一下 写一个类  继承HandlerInterceptorAdapter package co ...

  10. ORACLE 收集统计信息

    1.     理解什么是统计信息优化器统计信息就是一个更加详细描述数据库和数据库对象的集合,这些统计信息被用于查询优化器,让其为每条SQL语句选择最佳的执行计划.优化器统计信息包括: ·        ...