利用NSMutableAttributdString类
<span style="font-size:18px;">NSMutableAttributedString *str =[ [NSMutableAttributedString alloc] initWithString:@"按钮的文字"];
NSRange strRange = {0,[str length]};
[str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setAttributedTitle:str forState:UIControlStateNormal];</span>
本文介绍如何使用NSMutableAttributedString为UIButton设置带有下划线的文字效果,通过具体代码展示了NSAttributedString的使用方法。
1万+

被折叠的 条评论
为什么被折叠?



