如何在iOS按钮上的文字添加下划线

来源:爱站网时间:2021-01-15编辑:网友分享
在开发ios的时候很多用户们都会想如何在iOS按钮上的文字添加下划线,那么接下来的内容中我们就一起去看看在iOS按钮上的文字添加下划线的方法。

在开发ios的时候很多用户们都会想如何在iOS按钮上的文字添加下划线,那么接下来的内容中我们就一起去看看在iOS按钮上的文字添加下划线的方法。

问题:实现下图中右侧的按钮文字效果

方法:

[MyTools createMyImageview:topEditView frame:CGRectMake(widthAll-90, 12, 17, 16) imageName:@"离线课程_下载更多.png"];
UIButton *downMoreButton = [MyTools createMyBtn:@"下载更多" frame:CGRectMake(widthAll-70, 10, 60, 20) uiview:topEditView uifont:14 color:[UIColor colorWithRed:92/255.0 green:218/255.0 blue:231/255.0 alpha:1]];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"下载更多"];
NSRange titleRange = {0,[title length]};
[title addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:titleRange];
[downMoreButton setAttributedTitle:title
forState:UIControlStateNormal];
[downMoreButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
[downMoreButton addTarget:self action:@selector(downMore) forControlEvents:UIControlEventTouchUpInside];

看完后你知道如何在iOS按钮上的文字添加下划线了吗?希望可以帮助到大家,爱站技术频道小编会耐心解答大家的问题。

上一篇:iOS中关于UIScrollView的介绍

下一篇:iOS App中如何调用iPhone各种感应器

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载