iOS 带下划线的文字按钮

效果如图
这里写图片描述

//富文本
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"发送验证码"]];
    NSRange contentRange = {0,[content length]};
    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    //button的setAttributedTitle方法
    [button setAttributedTitle:content  forState:UIControlStateNormal];

你可能感兴趣的:(iOS备忘)