iOS UIButton设置下划线

采用富文本的形式增加下划线

- (void)SetUnderLine:(UIButton*)btn setTitle:(NSString*)title
{
    NSMutableAttributedString*str = [[NSMutableAttributedStringalloc]initWithString:title];
    NSRangestrRange = {0,[strlength]};
    [straddAttribute:NSUnderlineStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlineStyleSingle]range:strRange];
    [btnsetAttributedTitle:strforState:UIControlStateNormal];
}

你可能感兴趣的:(iOS UIButton设置下划线)