源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

iOS 按钮上的文字添加下划线的方法

  • 时间:2022-10-24 10:17 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:iOS 按钮上的文字添加下划线的方法
问题:实现下图中右侧的按钮文字效果 [img]http://files.jb51.net/file_images/article/201605/2016050410543829.png[/img] [b]方法:[/b]
[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 按钮上的文字添加下划线的方法就给大家介绍到这里,希望对大家有所帮助!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部