首页 > iOS中给button设置下划线,怎么将下划线和标题的距离分开一点

iOS中给button设置下划线,怎么将下划线和标题的距离分开一点

UIButton *unVcodeBtn = (UIButton *)[self.view viewWithTag:13];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc]initWithString:@"收不到验证码"];
NSRange titleRange= {0,[title length]};
[title addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:titleRange];
[unVcodeBtn setAttributedTitle:title forState:UIControlStateNormal];

AttributedString来设标题下划线,是没法控制下划线和文字之间间距的,用CoreText也一样。

如果一定要增加这个间距,只能用addSubView的方式在 button 上画一条线了。

【热门文章】
【热门文章】