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];

 

posted @ 2015-01-05 10:53  Zsmile  阅读(371)  评论(0编辑  收藏  举报

屛去雕饰,反近自然。