iOS 富文本類庫RTLabel

來源:互聯網
上載者:User

標籤:

 本文轉載至 http://blog.csdn.net/duxinfeng2010/article/details/9004749 

 

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

 

RTLabel基於富文本的格式,適用於iOS,類似HTML的標記。RTLabel 基於UILabel類的拓展,能夠支援Html標記的富文本顯示,它是基於Core Text,因此也支援Core Text上的一些東西。 特點
  • 粗體和斜體
  • 顏色和大小
  • 底線
  • 縮排
  • 字距
  • 行距
  • 超連結
用法1)將RTLabel.h 和 RTLabel.m 拖拽道你的工程中,匯入Core Text.framework。添加標頭檔 [cpp] view plaincopy
  1. #import "RTLabel.h"  

2)建立一個RTLabel [cpp] view plaincopy
  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)支援以下標籤 [html] view plaincopy
  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 

iOS 富文本類庫RTLabel

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.