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];
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
用
AttributedString来设标题下划线,是没法控制下划线和文字之间间距的,用CoreText也一样。如果一定要增加这个间距,只能用
addSubView的方式在 button 上画一条线了。