【iOS开发】---- RTLabel 自定义label
来源:互联网 发布:线性时不变系统 知乎 编辑:程序博客网 时间:2024/06/04 18:08
在我们应用中,经常会用到带下划线的label,比如“找回密码”。网上查了一下,RTLabel是一个非常不错的库。这里说一下使用:
1.将RTLabel.h 和 RTLabel.m直接拽入你的工程中;
2.引入 CoreText.framework;
3.初始化和使用:
RTLabel *forgotLb = [[RTLabel alloc] initWithFrame:CGRectMake(LINK_LABEL_x, LINK_LABEL_Y+10, LINK_LABEL_WIDTH+100, LINK_LABEL_HEIGHT)]; forgotLb.text = @"<a href='http://www.baidu.com'>Forgot password</a>"; forgotLb.delegate = self; forgotLb.userInteractionEnabled = YES; [_accountView addSubview:forgotLb];
这里是一个链接,代理方法是用来实现点击效果,代码如下:
- (void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSURL*)url{ LOG(@"Forgot password");}
下面是一些常用标签
<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>//文本缩进
再附上一个网上下载的例子:
猛戳这里下载Demo
- 【iOS开发】---- RTLabel 自定义label
- iOS开发之label
- IOS开发UI-------label
- RTLabel
- iOS开发笔记--描边label
- IOS 开发 可复制label
- RTLabel 可以让label显示某段文字带下划线
- iOS 富文本类库RTLabel
- iOS 富文本类库RTLabel
- iOS 富文本类库RTLabel
- iOS 富文本类库RTLabel
- iOS到Mac OS之自定义Label
- ios开发系列之label自适应大小
- iOS开发之label(自用贴)
- IOS开发基础03(Label,textField)
- ios开发 label分段设置字体颜色
- 自定义Label
- IOS-Label
- 多角度看.NET面试题
- Bigtable:A Distributed Storage System for Structured Data
- apt-get
- 信号client信号server
- FatFS文件系统
- 【iOS开发】---- RTLabel 自定义label
- shell资源(1)
- 【IOS】开发基础知识
- java-下载资源
- GCD介绍(四): 完结
- 内容随着下拉选项的动态变化
- js跳出iframe
- Autocomplete
- Google Protocol Buffer 的使用和原理