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 ...
随机推荐
- sharepoint 2010版本 图文安装
软件程序:Microsoft Perject Server2010 Microsoft Share Point2010(中文版) 操作系统:windows server 2008 sp1 64位 数 ...
- Altium Designer 快速修改板子形状为Keep-out layer大小
Altium Designer 快速修改板子形状为Keep-out layer大小 1,切换到 Keep-out layer层, 2,选择层,快捷键为S+Y: 3,设计>>板子形状> ...
- shell 分支/循环
==)); then patern="Update" else patern="Read" fi in "-h") ] then helpI ...
- IOS CALayer是什么
大家在开发IOS程序时,经常会遇到self.view.layer这个东西,我以前也是不求甚解,后来觉得有必要整理下. 简单介绍layer: 在IOS中,你能看得见摸得着的东西都是UIView,比如一个 ...
- JavaEE XML StAX创建
StAX创建XML文档 @author ixenos 1. 如果通过DOM树来创建XML文件时,发现这个DOM树没有其他用途,那么这种方式就不是很高效,这时我们可以使用StAX API直接将XML树写 ...
- CentOS 7上的性能监控工具
Linux中基于命令行的性能监控工具:dstat.top.netstat.vmstat.htop.ss.glances 1.dstat – 多类型资源统计工具(需配置epel源) 该命令整合了vmst ...
- redis配置文件redis.conf的参数说明
打开redis.conf文件: # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that R ...
- CodeForces 711C Coloring Trees
简单$dp$. $dp[i][j][k]$表示:前$i$个位置染完色,第$i$个位置染的是$j$这种颜色,前$i$个位置分成了$k$组的最小花费.总复杂度$O({n^4})$. #pragma com ...
- 内存/硬盘/io关系
CPU:工人,干活的,判断以及逻辑处理 硬盘:仓库,原料,数据存储 内存:车间,工人干活的地方,车间中加工原料,当车间中没有原料了,在从仓库中取原料,对原料进行加工 内存本身有一定的存储空间,对内存 ...
- 关于FlagsAttribute
最近在看C#本质论,有介绍FlagsAttribute的特性,看了下源码,发现只是一个简单的特性class和一个构造函数. 调试了一下.NET的源码,发现在console.writeline(***) ...