如何给button增加下划线简单版
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #cf8724; background-color: #fffcea }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #c35900; background-color: #fffcea }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #587ea8; background-color: #fffcea }
span.s1 { color: #36568a }
span.s2 { color: #c35900 }
span.s3 { color: #000000 }
span.s4 { color: #587ea8 }
- (void)setUnderLineForButton:(UIButton *)btn withTitle:(NSString *)title{
//利用富文本的方式增加button下划线
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:title];
NSRange strRange = {0,[str length]};
[str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
[btn setAttributedTitle:str forState:UIControlStateNormal];
}
原文地址:https://www.cnblogs.com/lsnow/p/9889471.html