分享

iOS 富文本类库RTLabel

 quasiceo 2015-06-21
分类: 菜鸟学iOS的笔记 2013-06-01 18:08 17315人阅读 评论(3) 收藏 举报

目录(?)[+]


本节关于RTLable基本介绍,原文来自 https://github.com/honcheng/RTLabel


RTLabel

基于富文本的格式,适用于iOS,类似HTML的标记。

RTLabel 基于UILabel类的拓展,能够支持Html标记的富文本显示,它是基于Core Text,因此也支持Core Text上的一些东西。

特点

  • 粗体和斜体
  • 颜色和大小
  • 下划线
  • 缩进
  • 字距
  • 行距
  • 超链接


用法

1)将RTLabel.h 和 RTLabel.m 拖拽道你的工程中,导入Core Text.framework。添加头文件
  1. #import "RTLabel.h"  

2)创建一个RTLabel
  1. NSString *sample_text = @"<b>bold</b>,<i>italic</i> and <u>underlined</u> text, and <font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00'>text with custom font and color</font>";  
  2.   
  3. RTLabel *label = [[RTLabel alloc] initWithFrame:...];  
  4. [self addSubview:label];  
  5. [label setText:sample_text];  

3)支持以下标签
  1. <b>Bold</b>  
  2. <i>Italic</i>  
  3. <bi>Bold & Italic</bi>  
  4. <u>underline</u><u color=red>underline with color</u>  
  5. <a href='http://..'>link</a>  
  6. <uu>double underline</uu> , <uu color='#ccff00'>double underline with color</uu>  
  7. <font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00'>custom font</font>  
  8. <font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00' stroke=1>custom font with strokes</font>  
  9. <font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00' kern=35>custom font with kerning</font>  
  10. <p align=justify>alignment</p>  
  11. <p indent=20>indentation</p>  

最低要求

  • ARC -RTLabel使用了ARC,如果你的工程没有使用ARC,在编译时 compiler flag 上 添加 '-fobjc-arc'(如下图显示)
  • XCode 4.4 或以上新版本




原创博客欢迎转载分享,请注明出处http://blog.csdn.net/duxinfeng2010




4
0
主题推荐
ios alignment compiler
猜你在找
查看评论
2楼 qq_22469771 2015-03-10 18:16发表 [回复]
为什么用ipone6模拟器会挂掉啊?其他模拟器都行,求解决办法。。。。
1楼 baidu_17475429 2014-07-24 15:06发表 [回复]
我创建了一个RTLabelTestVC类(用的xib),在viewDidLoad里边,创建RTLabel并赋值,但RTLabel不起作用,一片空白。 但在AppDelegate测试就没问题。
Re: duxinfeng2010 2014-07-25 16:43发表 [回复]
回复baidu_17475429:1.你查一下标签是否定定义有问题
2.你用xib文件关联线是否链接上
3.代码执行顺序,是否被其他View给覆盖住了
发表评论

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多