iOS开发富文本

NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc] initWithString:@"犯我中华者,虽远必诛"];
[attributedStr setAttributes:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:30]} range:NSMakeRange(0, 5)];
[attributedStr setAttributes:@{NSShadowAttributeName:[UIColor yellowColor],NSFontAttributeName:[UIFont systemFontOfSize:35]} range:NSMakeRange(2, 2)];
[attributedStr setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:215/255.0 green:0 blue:18/255.0 alpha:0.9],NSFontAttributeName:[UIFont systemFontOfSize:30]} range:NSMakeRange(6, 4)];
self.attributedStr.attributedText = attributedStr;
//属性值
// Predefined character attributes for text. If the key is not in the dictionary, then use the default values as described below.
NSFontAttributeName // UIFont, default Helvetica(Neue) 12
NSParagraphStyleAttributeName // NSParagraphStyle, default defaultParagraphStyle
NSForegroundColorAttributeName // UIColor, default blackColor
NSBackgroundColorAttributeName // UIColor, default nil: no background
NSLigatureAttributeName // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
NSKernAttributeName // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
NSStrikethroughStyleAttributeName // NSNumber containing integer, default 0: no strikethrough
NSUnderlineStyleAttributeName // NSNumber containing integer, default 0: no underline
NSStrokeColorAttributeName // UIColor, default nil: same as foreground color
NSStrokeWidthAttributeName // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)
NSShadowAttributeName // NSShadow, default nil: no shadow
NSTextEffectAttributeName // NSString, default nil: no text effect
NSAttachmentAttributeName // NSTextAttachment, default nil
NSLinkAttributeName // NSURL (preferred) or NSString
NSBaselineOffsetAttributeName // NSNumber containing floating point value, in points; offset from baseline, default 0
NSUnderlineColorAttributeName // UIColor, default nil: same as foreground color
NSStrikethroughColorAttributeName
NSObliquenessAttributeName
NSExpansionAttributeName
NSWritingDirectionAttributeName
NSVerticalGlyphFormAttributeName
/************************ Attribute values ************************/
iOS开发富文本的更多相关文章
- iOS开发富文本制作 图片和文字/NSMutableParagraphStyle/NSMutableAttributedString
/NSMutableParagraphStyle/NSMutableAttributedString 组合使 NSString * titlestr=@"日产GT-R"; NSMu ...
- iOS 开发富文本之TTTAttributedLabel 在某个特定位置的文字添加跳转,下划线,修改字体大小,颜色
@property(nonatomic , strong) TTTAttributedLabel * ttLabel; @property(nonatomic , strong) NSRange li ...
- draft.js开发富文本编辑器
写在前头的话 在react中去寻找一个好用的富文本编辑器网上很少有推荐的,搜到的也只有一些个人不成熟的作品,慢慢发现网上比较推荐的一个东东叫做draft.js. 这个东西在网上可以找到的教程也是手指头 ...
- iOS之富文本
之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结果在XCode中查 ...
- iOS之富文本(二)
之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结 ...
- iOS - NSMutableAttributedString富文本的实现
NSMutableAttributedString继承于NSAttributedString(带属性的字符串)能够简单快速实现富文本的效果;不多说直接上效果图和代码,通俗易懂: (一)效果图: (二) ...
- IOS开发计算文本尺寸
在IOS开发中例如微博,QQ聊天界面中要显示大量的文字信息,这样需要计算出文字部分的尺寸,才能设计出合适的控件尺寸和位置.下面是IOS 7.0计算文本尺寸的方法.- (CGRect)boundingR ...
- iOS swift 富文本显示 富文本在iOS中使用场景和解决方案
项目中很多地方都会用到富文本的内容:比如一般的商品详情,视频详情,资讯详情等,运营人员通过后台的富文本编辑器编辑的内容,前端拿到的就是一段富文本的字符串,这富文本大多都是图片和文字的组合.我们今天介绍 ...
- iOS计算富文本(NSMutableAttributedString)高度
有时候开发中我们为了样式好看, 需要对文本设置富文本属性, 设置完后那么怎样计算其高度呢, 很简单, 方法如下: - (NSInteger)hideLabelLayoutHeight:(NSStrin ...
随机推荐
- 概述java语言
1.java语言是什么? java是一门面向对象的高级语言,它吸收了c++语言的各种优点,还摒弃了C++里难以理解的多继承和指针等概念,因此Java语言具有功能强大和简单易用两个特征. 2.java语 ...
- Vmware(vmdk)虚拟机到hyperv(vhd)虚拟机转换
1.关闭Vmware所有虚拟机 2.合并Vmware磁盘 通常磁盘都分开储存 targetDisk.vmdk 3.转换vmdk到vhd 安装winimage http://www.winimage.c ...
- 常用的meta标签总结
<!-- 关键字,搜所引擎 SEO --><meta http-equiv="keywords" content="关键字1,关键字2,..." ...
- git 查看某个文件的历史修改版本
[git status 查看修改的文件路径] git log --follow -p routes/admin/contract_operation.js
- tuple 可更改的列表和不可更改的元组
tuple([iterable]) Return a tuple whose items are the same and in the same order as iterable's items. ...
- PRML 第二章mindmap
PRML第二章的Mindmap,这一章读的比较快,主要是很多计算和证明的过程都跳过了,感觉不是特别需要认真去看每一个公式,能够记住每个小节的结论.公式就可以了.当然有能力.有时间的人还是可以认真读的, ...
- MATLAB符号极限、导数及级数求和
作者:长沙理工大学 交通运输工程学院 王航臣 1.函数的极限 函数:limit 功能:求取函数的极限 语法: limit(f) limit(f,x,a) limit(f,x,a,'right') li ...
- Graph - leetcode [图]
207. Course Schedule 有向图的环检测 bool canFinish(int numCourses, vector<pair<int, int>>& ...
- Linux网络管理常用命令:net-tools VS iproute2
Exported from workflowy! net-tools ifconfigifconfig命令:用于接口及地址查看和管理 route netstat arp iproute2 ip lin ...
- .NET中的SqlBulkCopy类用法
在开发过程中,经常会遇到向数据库插入大量数据的情况,那么如果是百万条数据,一条条的插入实在是太慢了,所以就有了SqlBulkCopy类. 本文中我将示范SqlBulkCopy类的不同应用. 以下面三张 ...