zoukankan      html  css  js  c++  java
  • RTLabel 富文本

    本节关于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>, <color=red>underline with color</u>  
    5. <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. <align=justify>alignment</p>  
    11. <indent=20>indentation</p>  

    最低要求

    • ARC -RTLabel使用了ARC,如果你的工程没有使用ARC,在编译时 compiler flag 上 添加 '-fobjc-arc'(如下图显示)
    • XCode 4.4 或以上新版本。
     
     
     
    原创博客欢迎转载分享,请注明出处http://blog.csdn.net/duxinfeng2010
     
     
  • 相关阅读:
    Linux PHP连接MSSQL
    Curl参数一览
    [android开发必备] Android开发者社区汇总
    android定时器
    一个mysql小技巧
    php empty问题
    周报_2012第16周(2012/04/152012/04/21)
    周报_2012第17周(2012/04/222012/04/28)
    周报_2013第04周(2013/01/202013/01/26)
    周报_2013第01周(2012/12/302012/01/05)
  • 原文地址:https://www.cnblogs.com/seth-chen/p/4362573.html
Copyright © 2011-2022 走看看