iOS在一个label中显示不同颜色的字体
UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(20, 300, 300, 30)];
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"set background color with button"];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,2)];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:17.0] range:NSMakeRange(0, 5)];
[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:17.0] range:NSMakeRange(6, 12)];
[string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:17.0] range:NSMakeRange(19, 6)];
Label.attributedText = string;
[self.view addSubview:Label];
iOS在一个label中显示不同颜色的字体的更多相关文章
- 解决alert在ios版微信中显示url的问题(重写alert)
为了解决alert在ios版微信中显示url的问题 window.alert = function(name){ var iframe = document.createElement("I ...
- 小技巧,如何在Label中显示图片
这个需求其实是有的,比如QQ聊天界面里面发送的信息,可以用label来显示文字(也可以用button显示),但是有时候用户可能会发送图片.如果能让Label遇到文字就显示文字,遇到图片就显示图片就好了 ...
- iOS开发实现Label中多颜色多字体
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(8, 100, 300, 30)]; label.textColor = wor ...
- iOS 如何在Label中显示html的文本
if (self.messageModel) { NSString * htmlString = self.messageModel.contentText; NSAttributedString * ...
- label显示不同颜色的字体
NSString *contentSrt = [NSString stringWithFormat:@"%@ (%@)",categoryModel.categoryName, c ...
- iOS上用FTGL显示定制Truetype字体碰到的问题
没想到这个问题搞了快2个月时间:当然跟我只是断断续续地工作有关. FTGL是freetype的opengl实现.我接触FTGL最初只是为了练习OpenGL,写几个简单的游戏app.开始试了试FTGL觉 ...
- 在Label中显示一段文字
Let’s create a new Xamarin.Forms PCL solution, named Greetings, using the same process described abo ...
- 在一个Label上设置多种颜色字体
#import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL ...
- Python3 tkinter基础 LabelFrame StringVar 单击按钮,Label中显示的文字更换
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- 看 nova
本节重点介绍 nova-scheduler 的调度机制和实现方法:即解决如何选择在哪个计算节点上启动 instance 的问题. 创建 Instance 时,用户会提出资源需求,例如 CPU.内存.磁 ...
- Mysql Binlog日志文件介绍
一.Binlog简介 官方文档参考 https://dev.mysql.com/doc/refman/5.5/en/binary-log.html Binlog(Binary Log) 指数据库的表创 ...
- Codeforces 849B Tell Your World (计算几何)
题目链接 Tell Your World 题意 给出N个点(i, xi),问是否存在两条平行的直线,使得每一个点恰好在两条直线的其中一条上. 每条直线必须穿过至少一个点. 考虑每个点和第1个点的斜率, ...
- spark学习(六)Java版RDD基本的基本操作
1.map算子 private static void map() { //创建SparkConf SparkConf conf = new SparkConf() .setAppName(" ...
- Java全局变量不加修饰符时的访问权限范围
如上图所示.
- systemtap初体验
https://phpor.net/blog/post/3471 写在前面: systemtap依赖的debuginfo可以从这里(http://debuginfo.centos.org/6/x86_ ...
- flask-limiter限制单个IP访问的频率和次数
Flask-Limiter provides rate limiting features to flask routes. It has support for a configurable bac ...
- CentOS下常用的 19 条命令
玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令就可以了.当然你也可以在使用时去找一下 ...
- weexpack 的 Login.vue 及 vue 的 Login.vue
1.登录页 weexpack Login.vue <!-- 登录页 --> <template> <div class="wrapper"> ...
- TCP 的那些事儿(下)(转)
TCP的RTT算法 从前面的TCP的重传机制我们知道Timeout的设置对于重传非常重要, 设长了,重发就慢,没有效率,性能差: 设短了,重发的就快,会增加网络拥塞,导致更多的超时,更多的超时导致更多 ...