iOS之改变UIAlertViewController字体的颜色
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字体的颜色的更多相关文章
- UISegmentedControl 改变选中字体的颜色
//设置选中的字体颜色为蓝色 [segmentControll setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor ...
- 改变placeholder字体的颜色
/* Mozilla Firefox 19+ */ ::-moz-placeholder { color: #f00; } /* IE9+版本 */ input:-ms-input-placehold ...
- Lable 控件 -- 用代码改变要显示字体的颜色
lable控件怎么改变显示字体的颜色 代码如下: string color = "#B72C34"; this.lbl.ForeColor = System.Drawing.Col ...
- pycharm 控制台字体背景颜色设定让你美到爆
还在为你控制台字体颜色不入眼而发愁吗? 在某些特殊时刻想要改变下字体的颜色却无从下手而发愁吗? 那你就进来看一看,瞧一瞧,之需看2分钟,花2分钟理解,花3分钟练练手就能让你的控制能字体炫酷起来! 一. ...
- [iOS]改变UIAlertController的标题、内容的字体和颜色
https://www.jianshu.com/p/51949eec2e9c 2016.03.23 22:36* 字数 272 阅读 37401评论 54喜欢 72 在开发中,弹出框是必不可少的,通常 ...
- Android(java)学习笔记96:如何改变spinner系统自带的字体和颜色
1.首先我们要知道spinner系统自带字体和颜色本质: 原生的Spring 控件是无法更改字体和颜色的... 从下面的代码可以看出...红色的标注显示使用的是Android默认的布局.. Spinn ...
- WinForm开发中针对TreeView控件改变当前选择节点的字体与颜色
本文转载:http://www.cnblogs.com/umplatform/archive/2012/08/29/2660240.html 在B/S开发中,对TreeView控件要改变当前选中节点的 ...
- Android(java)学习笔记35:如何改变Spinner系统自带的字体和颜色
1. 首先我们要知道Spinner系统自带字体和颜色本质: 原生的Spring 控件是无法更改字体和颜色的... 从下面的代码可以看出...红色的标注显示使用的是Android默认的布局.. Spin ...
- 李洪强iOS开发之-修改状态栏的字体的颜色
李洪强iOS开发之-修改状态栏的字体的颜色 修改的效果: -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [ ...
随机推荐
- mui ajax 应用的跨域问题
1.首先在mui.ajax的error函数里出现: “syntaxerror unexpected token <” 这样的错误,那么在 mui.ajax中的type写成 JSONP ,后台需 ...
- CentOS 7运维管理笔记(1)----设置默认启动模式为GUI模式或命令行模式
昨天在虚拟机中安装CentOS 7时选择了GNOME模式安装,开机默认进入GUI模式.网上搜找修改为默认命令行模式的方法,看到说修改 /etc/inittab文件,在最低下一行添加 但是 使用 cat ...
- 22_CopyOnWrite容器
[简述] Copy-On-Write简称COW,是一种程序设计中的优化策略. JDK里的COW容器分为两种:CopyOnWriteArrayList 和 CopyOnWriteArraySet. Co ...
- python的继承多态以及异常处理
1.单继承 # 动物类 class Animal(object): def __init__(self, name): self. __name = name def run(self): print ...
- 基于容器微服务的PaaS云平台设计(一) 实现容器微服务和持续集成
版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 ,博主地址:http://www.cnblogs.com/SuperXJ/ 前言:关于什么是容器微服务PaaS和容器微服务PaaS的 ...
- css tips: 清除float影响,containing的div跟随floated sub等
/** * For modern browsers * 1. The space content is one way to avoid an Opera bug when the * content ...
- golang 安装 guru vscode 安装失败
1.先从git上复制下来 git clone https://github.com/golang/tools 2.再$GOPATH/bin中安装 go install golang.org/x/too ...
- 设置导出的excel数据
/** * 设置导出的excel数据 * @param type $objPHPExcel * @param type $colModel * @param type $grid */public f ...
- dubbox源码分析(一)-服务的启动与初始化
程序猿成长之路少不了要学习和分析源码的.最近难得能静得下心来,就针对dubbox为目标开始进行源码分析. [服务提供方] 步骤 调用顺序 备注 容器启动 com.alibaba.dubbo.conta ...
- CSS position属性 标签: css 2016-09-06 15:58 78人阅读 评论(0) 收藏
踩了position的坑,主要是因为对position属性理解不深. 以下是w3school中对position的解释: 可能的值 值 描述 absolute 生成绝对定位的元素,相对于 static ...