iOS之label添加下划线

UILabel *linkLabel = [[UILabel alloc]init];

linkLabel.frame = CGRectMake(10, introduceLabel.frame.origin.y +introduceLabel.frame.size.height +10, [UIScreen mainScreen].bounds.size.width - 20, 20);

NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",data[@"skipLinkText"]]];

NSRange contentRange = {0,[content length]};

[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];

linkLabel.attributedText = content;

linkLabel.textColor = [UIColor blueColor];

linkLabel.font = [UIFont systemFontOfSize:10];

[linkLabel setLineBreakMode:NSLineBreakByWordWrapping];

linkLabel.numberOfLines = 2;

CGSize maximumLabelSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 20, 9999);

CGSize expectSize = [linkLabel sizeThatFits:maximumLabelSize];

linkLabel.frame = CGRectMake(10, introduceLabel.frame.origin.y +introduceLabel.frame.size.height +10, expectSize.width, expectSize.height);

[self.infoScrollView addSubview:linkLabel];

时间: 2024-07-31 04:42:23

iOS之label添加下划线的相关文章

IOS UIlabel 、UIButton添加下划线

1.给UILabel 添加下划线 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)]; label.backgroundColor = [UIColor redColor]; label.numberOfLines = 3; NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString

iOS开发-UILabel和UIButton添加下划线

关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选择第一种,第二种有兴趣的可以自己研究一下. UILabel设置下划线: UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 310, 50)]; label.backgroundColor = [UIColor red

使用NSMutableAttributedString添加下划线、删除线、阴影、填充、不同字体颜色等

在iOS开发中,有时会遇到需要添加下划线,或者设置字符串中某几个字的颜色的情况,最常见的栗子就是注册页面,如图所示: 几乎所有注册页面中都会出现这么一句话 "点击下一步表示您已同意<用户服务协议>",而且可以看到,"<用户服务协议>"几个字是橙色的,并且它们下面还有下划线.这是怎么实现的呢? 有的同学可能会说:"不同颜色就设置两个label,让左边的label显示前半句并设置为黑色,让右边的label显示后半句并设置为橙色就行了.&

网页中添加下划线的方法汇总及优缺点

本文主要介绍了添加下划线样式的几乎所有方法,并且比较了每一种方法的优缺点.没想到之前一直没有注意的下划线还有这么多玄机奥秘! 本文由 nzbin 翻译,艾凌风 校稿.未经许可,禁止转载! 英文出处:css-tricks.com 发表地址:http://web.jobbole.com/89425/ 有很多种添加下划线样式的方法.可能你还记得< Crafting link underlines on Medium >这篇文章.Medium 并没有尝试特殊的方法,只是想创建一个漂亮的看起来正常的下划

给label绘制下划线

UIlabel本身没有下划线的属性,使用绘制的方法,添加下滑下,并且赋给该label一个action作为响应方法,实现DIY超链接的效果. //调用 #import "UnderLineLabel.h" UnderLineLabel *label = [[UnderLineLabel alloc] initWithFrame:CGRectMake(50, 200, 300, 30)]; [label setBackgroundColor:[UIColor clearColor]]; /

html超链接添加下划线

在需要的连接添加行内样式: <a href="ddrb/090630.asp" target="_blank" style="text-decoration:underline;">30</a> CSS text-decoration 属性 可能的值 值 描述 none 默认.定义标准的文本. underline 定义文本下的一条线. overline 定义文本上的一条线. line-through 定义穿过文本下的一条线

给Label加下划线、中划线

添加中划线: p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3495af } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 1

android textView 替文字添加下划线 删除线

android textView 为文字添加下划线 删除线android textview 添加下划线 中划线 删除线tv=(TextView)findViewById(R.id.tvId);tv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); //删除线//Paint.UNDERLINE_TEXT_FLAG 下划线 XAMARIN: TextView text = FindViewById<TextView>(Resource.Id.xxx

【界面优化】使用viewpagerindicator添加下划线滑动动画

开源代码viewpagerindicator里面没有实现tab下划线切换过程中的移动动画,都是很突兀的多个fragement之间的切换,导致用户体验略差,google了下相关问题,发现一片博文: http://blog.csdn.net/lancees/article/details/9164421 重点是如下代码: public class UnderlinePageIndicatorEx extends UnderlinePageIndicator{ public UnderlinePage