我想将我的UIButton标题设置为=== Don`t有一个帐户? 注册
如何制作一些大胆的文字。
UIButton *signUpButton = [[UIButton alloc]initWithFrame:CGRectMake(40, 270, 240, 40)];
[signUpButton setTitle:@"Don`t have an account? Sign Up" forState:UIControlStateNormal];
[signUpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
signUpButton.titleLabel.font = [UIFont systemFontOfSize:14];
[signUpButton setBackgroundColor:[UIColor clearColor]];
[signUpButton addTarget:self action:@selector(signUpAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:signUpButton];
无法实现属性字符串..
答案 0 :(得分:9)
在这里设置你的按钮文字......
[yourbutton setAttributedTitle:[self UnderLineTextString:strString]
forState:UIControlStateNormal];
请尝试此功能......
-(NSMutableAttributedString *)UnderLineTextString:(NSString *)str
{
NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:str];
[titleString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:20.0] range:NSMakeRange(0, [titleString length])];// set your text lenght..
return titleString;
}