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 ...
随机推荐
- 第一百三十五节,JavaScript,封装库--拖拽
JavaScript,封装库--拖拽 封装库新增1个拖拽方法 /** tuo_zhuai()方法,将一个弹窗元素实现拖拽功能 * 注意:一般需要在css文件将元素里的某一个区块光标设置成提示可以拖拽, ...
- [前端性能提升]--图片转化为base64
图片的 base64 编码就是可以将一副图片数据编码成一串字符串,使用该字符串代替图像地址 意义:网页上的每一个图片,都是需要消耗一个 http 请求下载而来的(所有才有了 csssprites 技术 ...
- ShopNC_WAP
记录 ShopNC_WAP 端点点滴滴 插件记录 1. http://www.jiawin.com/swipe-mobile-touch-slider swiper 插件 2. https:// ...
- [Q]打印机页边距设置
问题描述:当您在使用CAD批量打图精灵默认设置打印图纸(使用pdfFactory虚拟打印机),可能会发现打印出的图纸页边距比您手工打印(使用Adobe或系统打印机)的要偏大. Adobe虚拟打印机打印 ...
- Storm 1.0.0
Storm 1.0.0版本增加了很多新的特性,可用性以及性能也得到了很大的改善,该版本是Storm发展历程上一个里程碑式的版本,主要特点如下. 性能提升 Storm 1.0.0版本最大的亮点就是性能提 ...
- asp.net如何把一个tostring类型转化为dateTime类型
Convert.ToDateTime(dr["consult_DealTime"].ToString()).ToString("yyyy-MM-dd"); co ...
- Leetcode-37-Sudoku Solver(Hard)
此处先留空 使用搜索和回溯,递归来实现 参考:http://blog.csdn.net/zxzxy1988/article/details/8586289 描述简介,代码量最少
- NGINX----源码阅读---config配置脚本
config文件为nginx的配置入口文件. 1. #!/bin/sh # Copyright (C) Igor Sysoev # Copyright (C) Nginx, Inc. LC_ALL=C ...
- libvirt里的面向对象的C语言
C语言:类的声明和定义 // 通用父类的定义 struct _virClass { virClassPtr parent; unsigned int magic; char *name; size_t ...
- javascript variables 变量
一,调试方法: 1.document.write(); 直接在网页中显示. 2.alert(); 弹窗显示. 3.console. ...