给button增加下划线
程序员文章站
2022-06-30 12:18:38
如何给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];
}