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 ...
随机推荐
- android 轮播图
轮播图是很常用的一个效果 核心功能已经实现 没有什么特殊需求 自己没事研究的 所以封装的不太好 一些地方还比较糙 为想要研究轮播图的同学提供个参考 目前测试图片为mipmap中的图片 没有写从网络加载 ...
- 浅谈JAVA中字符串常量的储存位置
在讲述这些之前我们需要一些预备知识: java中的内存被分成以下部分: 1.栈区:由编译器自动分配释放,具体方法执行结束后,系统自动释放JVM内存资源. 其作用有保存局部变量的值,包括:1.用来保存基 ...
- 三、spark入门:文本中发现5个最常用的word,排除常用停用词
package com.yl.wordcount import java.io.File import org.apache.spark.{SparkConf, SparkContext} impor ...
- json字符串参数
jsp部分 json字符串的属性应该都是实体类的属性 function saveCashier(){ layer.closeAll(); var Reapply = document.g ...
- 文档在线预览开源实现方案三:OpenOffice + PDFRenderer + js
之前的方案无法很好地解决异构平台及不同浏览器的兼容性问题,如方案一需要客户端浏览器支持flash而移动端浏览器无法支持这点,虽然移动端浏览器支持方案二,但是一些老版本的IE浏览器无法支持,例如IE8就 ...
- maven项目如何引用本地的jar包
下载该jar包到本地(如下载目录结构为:D:\Users\lu.wang\Downloads\searchservice\searchservice\jar\ttd.search.searchserv ...
- nginx在window上无法启动的问题
内容列表: 简要介绍 下载安装 配置测试 一.简要介绍 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP ...
- USACO 3.3 Riding the Fences
Riding the Fences Farmer John owns a large number of fences that must be repaired annually. He trave ...
- Another Array of Orz Pandas
Another Array of Orz Pandas 题目链接:http://acm.xidian.edu.cn/problem.php?id=1187 线段树 线段树维护区间和以及区间内各个数平方 ...
- css基础和心得(二)
css中的某些样式是具有继承性的.它允许样式不仅应用于某个特定html标签元素 而且应用于其后代.如: p{color:red;} <p>dsffd<spans>sdfasd ...