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]; [ ...
随机推荐
- JSTL数据格式化
日期表示 <fmt:formatDate value="${DATE1}" pattern="yyyy-MM-dd hh:mm:ss" type=&quo ...
- 03_Adaptive注解
[Adaptive注解] package com.alibaba.dubbo.common.extension; import com.alibaba.dubbo.common.URL; import ...
- ES6入门——变量的解构赋值
1.数组的解构赋值 以前为变量复制,只能直接指定值.现在ES6允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring). 本质上,这种写法属于模式匹配,只要等 ...
- Qt QDialog将窗体变为顶层窗体(activateWindow(); 和 raise() )
m_pLoginDlg->hide(); m_pLoginDlg->activateWindow(); //m_pLoginDlg->raise(); m_pLoginDlg-> ...
- 比特币钱包Armory使用指南
转自:http://news.yibite.com/application/2014/0525/21603.shtml 比特币钱包Armory(https://bitcoinarmory.com/)是 ...
- 仿照jQuery进行一些简单的框架封装(欢迎指教~)
(function(window,undefined){ var arr = [], push = arr.push, slice = arr.slice; //首先要做的就是封装一个parseHtm ...
- OLED中的Demura
OLED作为一种电流型发光器件已越来越多地被应用于高性能显示中.由于它自发光的特性,与LCD相比,AMOLED具有高对比度.超轻薄.可弯曲等诸多优点.但是,亮度均匀性和残像仍然是它目前面临的两个主要难 ...
- linux下生成带符号的随机密码
cat /dev/urandom |tr -dc "[:graph:]"|fold -w 15|head 结果如下:
- MARKS:路由器桥接
仅供参考…… 测试使用环境:Tplink & Tenda渣渣路由器.其他环境或不同. 设置注意事项:副路由器网段设置和主路由一致.主路由不需要开启WDS.副路由器开启WDS(连接ok,状态即显 ...
- DQN核心思想理解
看过Deep learning(convolutional neural network),看过RL(Q-learning).但是在两者结合这一块一直弄不明白. 我的疑问在于一直不明白DL是怎样识别出 ...