RTLabel常见的设置标签

在我们应用中,经常会用到带下划线的label,比如“找回密码”。网上查了一下,RTLabel是一个非常不错的库。这里说一下使用:

1.将RTLabel.h 和 RTLabel.m直接拽入你的工程中;

2.引入 CoreText.framework;

3.初始化和使用:

  1.     RTLabel *forgotLb = [[RTLabel alloc] initWithFrame:CGRectMake(LINK_LABEL_x, LINK_LABEL_Y+10,
  2.                                                                   LINK_LABEL_WIDTH+100, LINK_LABEL_HEIGHT)];
  3.     forgotLb.text = @"<a href='http://www.baidu.com'>Forgot password</a>";
  4.     forgotLb.delegate = self;
  5.     forgotLb.userInteractionEnabled = YES;
  6.     [_accountView addSubview:forgotLb];
复制代码
这里是一个链接,代理方法是用来实现点击效果,代码如下:
  1. - (void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSURL*)url
  2. {
  3.     LOG(@"Forgot password");
  4. }
复制代码
下面是一些常用标签
  1. <b>Bold</b> //加粗
  2. <i>Italic</i> //斜体
  3. <bi>Bold & Italic</bi> //同时加粗斜体
  4. <u>underline</u>  //下划线
  5. <u color=red>underline with color</u>  // 下划线和颜色
  6. <a href='http://..'>link</a>  //链接
  7. <uu>double underline</uu>   //双下划线
  8. <uu color='#ccff00'>double underline with color</uu> //双下划线和颜色
  9. <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>//空心的字体
  10. <font face='HelveticaNeue-CondensedBold' size=20 color='#CCFF00' kern=35>custom font with kerning</font>//可以调整字之间的间距
  11. <p align=justify>alignment</p>//单词两端对齐<p indent=20>indentation</p>//文本缩进
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值