NSMutableAttributedString
带属性的字符串(NSMutableAttributedString)的使用
//带有属性的文字
//1.创建对象
NSString *original = @"今天你还好吗?";
NSMutableAttributedString *attrTitle = [[NSMutableAttributedStringalloc] initWithString:original];
//2.设置颜色(NSForegroundColorAttributeName代表要设置颜色, value代表值, range 代表范围)
/**
其他设置:
1.NSForegroundColorAttributeName //颜色
2.NSFontAttributeName //字体
3.NSBackgroundColorAttributeName //背景色
//还有其他的很多的属性,可以自己去看苹果的API,这里不再详述
*/
[attrTitle addAttribute:NSForegroundColorAttributeName value:[UIColorblueColor] range:NSMakeRange(0, 2)];
//3.添加到Label中
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(100, 100, 100, 40);
[label setAttributedText:attrTitle];
[self.view addSubview:label];
NSMutableAttributedString相关推荐
- 字符串的html语言,html语言解析为属性字符串NSMutableAttributedString
NSString *htmlString=[NSString stringWithFormat:@" %@",html语言字段]; NSMutableAttributedStrin ...
- 第三十三篇、富文本 NSMutableAttributedString
// 设置颜色等NSMutableDictionary *arrDic = [NSMutableDictionary dictionary];arrDic[NSForegroundColorAttri ...
- iOS使用NSMutableAttributedString实现富文本
转载自:http://snowyshell.blog.163.com/blog/static/2209140342014475383375/ 2014-05-07 17:38:33| 分类: iOS ...
- iOS NSMutableAttributedString常用方法总结
NSAttributedString 叫做富文本,是一种带有属性的字符串,通过它可以轻松的在一个字符串中表现出多种字体.字号.字体大小等各不相同的风格,还可以对段落进行格式化,一般都是对可变富文本(N ...
- 带属性的字符串(NSMutableAttributedString)的使用
//带有属性的文字 //1.创建对象 NSString *original = @"今天你还好吗?"; NSMutableAttributedString *attrTitle = ...
- 富文本处理NSMutableAttributedString
概述 富文本处理在项目中使用率越来越高.比如像颜色改变突出, 大字号突出处理, 下划线处理, 中划线(删除线)处理等等 详细 代码下载:http://www.demodashi.com/demo/10 ...
- 【转】iphone开发中NSMutableAttributedString/NSAttributedString 富文本设置
http://stackoverflow.com/questions/11031623/how-can-i-use-attributedtext-in-uilabel 一.设置UILabel的属性at ...
- NSMutableAttributedString图文并茂
通过下面代码可以通过NSTextAttachment将图片以附件的形式插入到属性文字中来达到图文并茂效果: class ViewController: UIViewController {@IBOut ...
- 使用NSMutableAttributedString添加下划线、删除线、阴影、填充、不同字体颜色等
在iOS开发中,有时会遇到需要添加下划线,或者设置字符串中某几个字的颜色的情况,最常见的栗子就是注册页面,如图所示: 几乎所有注册页面中都会出现这么一句话 "点击下一步表示您已同意<用 ...
最新文章
- MPB:中科院城环所杨军组-​​淡水浮游动物的采集及鉴定
- 又拍网架构中的分库设计
- 如何排查 .NET 内存泄漏
- js根据毫米/厘米算像素px
- linux搜索pdf文件,桌面应用|如何使用 pdfgrep 从终端搜索 PDF 文件
- dijkstra算法代码_数据科学家需要知道的5种图算法(附代码)
- RabbitMQ 下载、安装、配置、验证_rpm版本(Linux环境)
- [luogu4133 BJOI2012] 最多的方案 (计数dp)
- POJ3122-Pie
- 人脸检测——RetinaFace
- 在html中书名号怎么写,html范本
- HDFS BALANCER
- alios things开发板_AliOS Things开发:让你的开发板支持AliOS Studio调试-阿里云开发者社区...
- 安装NTFS For Mac时显示文件已损坏怎么办
- pdf怎么编辑连续页码
- 经济危机下,中国软件外包产业的走向
- 英语厉害的人,90%都做对了这件事!年薪百万大神一句话揭穿英语学习真相!...
- 基于DSTATCOM无功补偿的风电并网模型
- Inkscape裁剪图片(pdf,svg,png,jpg)
- android 重力感应和屏幕旋转关系
热门文章
- 技嘉电脑怎么开启vt模式?
- Loadrunner11 录制手机App脚本多种方法介绍
- python怎么念1001python怎么念-python 星号的使用
- 转载05:全能程序员学习路线
- Blend for Visual Studio 让XAML也可以像WinForm一样可视化设计,Blend 与Studio的区别
- 软工实践(五)——获小黄衫有感
- 微信支付小程序支付和APP支付
- mysql常见函数面试题_MySql三到常见面试题,整理总结一下
- 2007年大学生电子设计大赛国赛电源类题目设计报告
- APT组织最喜欢的工具 Cobalt Strike (CS) 实战