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开发富文本的更多相关文章

  1. iOS开发富文本制作 图片和文字/NSMutableParagraphStyle/NSMutableAttributedString

    /NSMutableParagraphStyle/NSMutableAttributedString 组合使 NSString * titlestr=@"日产GT-R"; NSMu ...

  2. iOS 开发富文本之TTTAttributedLabel 在某个特定位置的文字添加跳转,下划线,修改字体大小,颜色

    @property(nonatomic , strong) TTTAttributedLabel * ttLabel; @property(nonatomic , strong) NSRange li ...

  3. draft.js开发富文本编辑器

    写在前头的话 在react中去寻找一个好用的富文本编辑器网上很少有推荐的,搜到的也只有一些个人不成熟的作品,慢慢发现网上比较推荐的一个东东叫做draft.js. 这个东西在网上可以找到的教程也是手指头 ...

  4. iOS之富文本

    之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结果在XCode中查 ...

  5. iOS之富文本(二)

    之前做项目时遇到一个问题:          使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结 ...

  6. iOS - NSMutableAttributedString富文本的实现

    NSMutableAttributedString继承于NSAttributedString(带属性的字符串)能够简单快速实现富文本的效果;不多说直接上效果图和代码,通俗易懂: (一)效果图: (二) ...

  7. IOS开发计算文本尺寸

    在IOS开发中例如微博,QQ聊天界面中要显示大量的文字信息,这样需要计算出文字部分的尺寸,才能设计出合适的控件尺寸和位置.下面是IOS 7.0计算文本尺寸的方法.- (CGRect)boundingR ...

  8. iOS swift 富文本显示 富文本在iOS中使用场景和解决方案

    项目中很多地方都会用到富文本的内容:比如一般的商品详情,视频详情,资讯详情等,运营人员通过后台的富文本编辑器编辑的内容,前端拿到的就是一段富文本的字符串,这富文本大多都是图片和文字的组合.我们今天介绍 ...

  9. iOS计算富文本(NSMutableAttributedString)高度

    有时候开发中我们为了样式好看, 需要对文本设置富文本属性, 设置完后那么怎样计算其高度呢, 很简单, 方法如下: - (NSInteger)hideLabelLayoutHeight:(NSStrin ...

随机推荐

  1. 办理阿尔伯塔大学(本科)学历认证『微信171922772』Alberta学位证成绩单使馆认证University of Alberta

    办理阿尔伯塔大学(本科)学历认证『微信171922772』Alberta学位证成绩单使馆认证University of Alberta Q.微信:171922772办理教育部国外学历学位认证海外大学毕 ...

  2. Access一些常用的SQL语句

    您可以将 Microsoft Office Access 2013 用作创建.修改数据库以及处理数据的工具,还可将 Office Access 2013 用作服务器数据库管理系统(如 Microsof ...

  3. java 报表到excel

    现加个jar包 http://pan.baidu.com/s/1boe5kXh   vfp8 然后代码 package makeReportToExcel; import java.io.File; ...

  4. 未能加载文件或程序集"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad的真正解决办法

    未能加载文件或程序集"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3 ...

  5. SHELL中,如何分割字符串

    done.csv中,形如 amoy9812@163.com的数据 #!/bin/shwhile read linedo ar=(${line//@/ }) echo ${ar[0]} #说明:分解出账 ...

  6. python 数据清洗之字符串处理

    在数据分析中,特别是文本分析中,字符处理需要耗费极大的精力, 因而了解字符处理对于数据分析而言,也是一项很重要的能力. 字符串处理方法 首先我们先了解下都有哪些基础方法 首先我们了解下字符串的拆分sp ...

  7. 动态网站加速,cdn义不容辞

    "双十一"大战已经落下帷幕,各大电商纷纷拿出了亮眼的成绩单,但在这些成绩单的背后,CDN加速技术是功不可没的.随着互联网的发展,电商.视频直播等网站的火热,以及各个云加速平台的流行 ...

  8. js遍历数组对象和非数组对象

    //---------for用来遍历数组对象 var i,myArr = ["a","b","c"]; ; i < myArr.len ...

  9. js时间戳转换时间格式

    function getLocalTime(time){ if(time > 0){ var dateStr = new Date(time * 1000); var str = "& ...

  10. IOS开发自定义tableviewcell的注意点😄

    自定义tableviewcell 1.xib,nib拖控件:awakefromnib: 设置2,不拖控件:- (instancetype)initWithStyle:(UITableViewCellS ...