swift label不同颜色、不同字体
let string = "点击注册按钮,即表示您已同意隐私条款和服务协议"
let ranStr = "同意"
let attrstring:NSMutableAttributedString = NSMutableAttributedString(string:string)
let str = NSString(string: string)
let theRange = str.range(of: ranStr)
attrstring.addAttribute(NSForegroundColorAttributeName, value: UIColor.red, range: theRange)
attrstring.addAttribute(NSFontAttributeName, value: UIFont.systemFont(ofSize: 14), range: theRange)
label.attributedText = attrstring
swift label不同颜色、不同字体的更多相关文章
- label 不同颜色
label 不同颜色 UILabel* noteLabel = [[UILabel alloc] init]; noteLabel.frame = CGRectMake(60, 100, 200, ...
- 一个label两种颜色,一个label两种字体
-(void)addLabel{ UILabel *label = [[UILabel alloc]init]; label.backgroundColor = [UIColor grayColor] ...
- 一个label 混搭不同颜色,不同字体的文字.. by 徐
效果如图箭头所示,只需要一个label就可以做到不同颜色或不同字体的效果 1 UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, ...
- swift - label字体 倾斜,加粗
/* label.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];//加粗 label.font = [UIFont ...
- swift - label 的font 设置 文字字体和大小
设置字体和颜色 lab.textColor = UIColor.init(hexColor: "795928") lab.font = UIFont.systemFont(ofSi ...
- iOS在一个label中显示不同颜色的字体
UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(20, 300, 300, 30)]; NSMutableAttributedSt ...
- label显示不同颜色的字体
NSString *contentSrt = [NSString stringWithFormat:@"%@ (%@)",categoryModel.categoryName, c ...
- iOS中动态计算不同颜色、字体的文字高度
在改项目bug的时候,有一个问题动态计算label的高度,前开发者竟然用字符串长度除以14.16这样的常量来计算是否换行,结果cell的高度问题非常严重. 因为label内容里有部分关键字是要另一种颜 ...
- echarts pie 图表 显示的label 中内容 字体大小自定义
option = { tooltip: { trigger: 'item', formatter: "{a} <br/>{b}: {c} ({d}%)" }, lege ...
随机推荐
- Weka开发[3]-Evaluation类
上一次最后的结果就是一个分类的值,可能让大家大失所望,这一次会给大家一个比较完美的答案,这就是Evaluation类,这次只讲一下最简单的用法,首先初始化一个Evaluation对象,Evaluati ...
- jQuery判断浏览器类型
if ($.browser.msie) { alert("IE浏览器"); } else if ($.browser.opera) { alert("opera浏览器&q ...
- Fluent Nhibernate code frist简单配置
Fluent Nhibernate code frist简单配置 前言 在以前的项目开发过程中使用nhibernate做完orm映射工具需要编写大量的xml映射文件,项目过程中往往会因为一个字段等 ...
- iOS多线程的初步研究
iOS多线程的初步研究(四) 理解run loop后,才能彻底理解NSTimer的实现原理,也就是说NSTimer实际上依赖run loop实现的. 先看看NSTimer的两个常用方法: + (NST ...
- WCF学习笔记之事务编程
WCF学习笔记之事务编程 一:WCF事务设置 事务提供一种机制将一个活动涉及的所有操作纳入到一个不可分割的执行单元: WCF通过System.ServiceModel.TransactionFlowA ...
- FpGrowth算法
FpGrowth算法 频繁项集与关联规则挖掘(2)--FpGrowth算法 上一篇介绍了关联规则挖掘的一些基本概念和经典的Apriori算法,Aprori算法利用频繁集的两个特性,过滤了很多无关的 ...
- C++ Config 配置文件类
C++ Config 配置文件类 本文Config类的序列化和反序列化使用的jsoncpp, 因为jsoncpp提供的方法很简单易阅读.配置文件的格式自然也是json. 1 { 2 "ima ...
- linuxmint 15/ ubuntu 13.04 install OpenERP client 6.0.4
As we all know OpenERP is a great open-source ERP/CRM project. It does help people a lot when workin ...
- linux 消息队列例子
/author:DriverMonkey //phone:13410905075 //mail:bookworepeng@Hotmail.com //qq:196568501 #include < ...
- [ios-必看] IOS调试技巧:当程序崩溃的时候怎么办 iphone IOS
from:http://article.ityran.com/archives/1143 有这样一种情形:当我们正在快乐的致力于我们的app时,并且什么看都是无比顺利,但是突然,坑爹啊,它崩溃了.(悲 ...