如何給button增加下劃線簡單版 - (void)setUnderLineForButton:(UIButton *)btn withTitle:(NSString *)title{ //利用富文本的方式增加button下劃線 NSMutableAttributedString *str = [[ ...
如何給button增加下劃線簡單版
- (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];
}