UILabel和UIButton添加下划线
关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的 NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选择第一种,第二种有兴趣的可以自己研究一下。
UILabel设置下划线:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 310, 50)];
label.backgroundColor = [UIColor redColor];
[label setLineBreakMode:NSLineBreakByWordWrapping];
label.numberOfLines =3;
[label setFont:[UIFont systemFontOfSize:14]];
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"博文地址:http://www.cnblogs.com/xiaofeixiang 博客园-FlyElephant QQ群:228407086"]];
NSRange contentRange = {0,[content length]};
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
label.attributedText = content;
[self.view addSubview:label];</pre><br>
UIButton设置下划线:
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(10, 200, 80, 30)];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"FlyElephant"];
NSRange titleRange = {0,[title length]};
[title addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:titleRange];
[button setAttributedTitle:title
forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor redColor]];
[button.titleLabel setFont:[UIFont systemFontOfSize:14]];
[self.view addSubview:button];
UILabel和UIButton添加下划线的更多相关文章
- iOS开发-UILabel和UIButton添加下划线
关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选择 ...
- IOS UIlabel 、UIButton添加下划线
1.给UILabel 添加下划线 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )]; label.backgrou ...
- UILabel,文字添加下划线,中划线
//显示下划线 //中划线 // NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber nu ...
- vim显示行号、语法高亮、自动缩进、添加下划线的设置
ubuntu默认是没有安装vim的,所以设置以前请先安装vim:sudo apt-get install vim. 然后 打开vim的配置文件:sudo vim /etc/vim/vimrc 或者 s ...
- Android 给EditText添加下划线
在安卓高版本,默认是有下划线的,其默认下划线的颜色是由其主题颜色来控制的! 控制如下: <style name="AppTheme" parent="Theme.A ...
- "为文本添加下划线"组件:<u> —— 快应用组件库H-UI
 <import name="u" src="../Common/ui/h-ui/text/c_tag_underline"></impor ...
- TextView 为部分文字添加下划线,并实现单击事件
在开发应用的过程中经常会遇到显示一些不同的字体风格的信息,如关键词高亮显示的等.对于类似的情况,一般我们会想着使用多个TextView去实现,对于每个TextView设置不同的字体风格来满足需求. ...
- 【界面优化】使用viewpagerindicator添加下划线滑动动画
开源代码viewpagerindicator里面没有实现tab下划线切换过程中的移动动画,都是很突兀的多个fragement之间的切换,导致用户体验略差,google了下相关问题,发现一片博文: ht ...
- [UGUI]图文混排(五):添加下划线
0.下划线标签 标签格式:<material=underline c=#ffffff h=1 n=*** p=***>blablabla...</material> mater ...
随机推荐
- Microsoft Dynamics CRM Server 2013软件安装要求
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveV9mMTIz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...
- com.sun.jdi.InvocationException occurred invoking method 异常
参考链接:https://stackoverflow.com/questions/4123628/com-sun-jdi-invocationexception-occurred-invoking-m ...
- Objective-C面向对象-对象和类
文章都是先由本人个人博客:孙占兴:www.teilim.com,先更新,随后CSDN博客才会更新,掌握第一动态请关注本人主站. 原文链接:http://www.teilim.com/objective ...
- ORA-07445 第一參数为:kkqljpmpr
在版本号11.2.0.1.0上,在pl/sql developer中运行一条SQL会导致连接中断,这样的错误要到trace文件夹下找到错误日志文件,再定位.查了一下资料,是这个版本号的bug. D ...
- Intel Developer Forum
http://en.wikipedia.org/wiki/Intel_Developer_Forum Intel Developer Forum From Wikipedia, the free en ...
- 关于 underscore 中模板引擎的应用演示样例
//关于 underscore 中模板引擎的应用演示样例 <!doctype html> <html> <head> <meta charset=" ...
- java远程调用rmi入门实例
RMI是Java的一组拥护开发分布式应用程序的API.RMI使用Java语言接口定义了远程对象,它集合了Java序列化和Java远程方法协议(Java Remote Method Protocol). ...
- leetcode -day17 Path Sum I II & Flatten Binary Tree to Linked List & Minimum Depth of Binary Tree
1. Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such tha ...
- Axure Base 08 动态面板的用途
写了几个Axure教程之后发现,可能教程的起点有些高了,过分的去讲效果的实现,而忽略了axure功能以及基础元件的使用,那么从这个教程开始,把这些逐渐的展开讲解. 关于动态面板 动态面板是axure原 ...
- 成本函数计算方法J
J = 1/(2*m) * sum((X*theta - y).^2); OR