iOS 富文本類庫RTLabel


本節關於RTLable基本介紹,原文來自 https://github.com/honcheng/RTLabel
html


RTLabel

基於富文本的格式,適用於iOS,相似HTML的標記。

RTLabel 基於UILabel類的拓展,可以支持Html標記的富文本顯示,它是基於Core Text,所以也支持Core Text上的一些東西。

特色

  • 粗體和斜體
    git

  • 顏色和大小github

  • 下劃線ide

  • 縮進spa

  • 字距.net

  • 行距htm

  • 超連接blog


用法

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

2)建立一個RTLabel
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>";
RTLabel *label = [[RTLabel alloc] initWithFrame:...];
[self addSubview:label];
[label setText:sample_text];

3)支持如下標籤
<b>Bold</b>
<i>Italic</i>
<bi>Bold & Italic</bi>
<u>underline</u>, <u color=red>underline with color</u>
<a href='http://..'>link</a>
<uu>double underline</uu> , <uu color='#ccff00'>double underline with color</uu>
<font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00'>custom font</font>
<font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00' stroke=1>custom font with strokes</font>
<font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00' kern=35>custom font with kerning</font>
<p align=justify>alignment</p>
<p indent=20>indentation</p>

最低要求

  • ARC -RTLabel使用了ARC,若是你的工程沒有使用ARC,在編譯時 compiler flag 上 添加 '-fobjc-arc'(以下圖顯示)get

  • XCode 4.4 或以上新版本。it


相關文章
相關標籤/搜索