iOS学习-创建带下划线的button

 1     UIButton *tempBtn = [UIButton buttonWithType: UIButtonTypeCustom];
 2     tempBtn.frame = CGRectMake(50, 250, 80, 40);
 3     
 4     NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"忘记密码"];
 5     NSRange strRange = {0,[str length]};
 6     [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
 7     [tempBtn setAttributedTitle:str forState:UIControlStateNormal];
 8     
 9     tempBtn.titleLabel.textColor = [UIColor blueColor];
10     [self.view addSubview: tempBtn];
原文地址:https://www.cnblogs.com/Zsmile/p/4203015.html