我正在以编程方式创建UIButton
。
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(0,0,160, 160)];
[button setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[button setTitle:@"title" forState:UIControlStateNormal];
button.titleLabel.font = [UIFont fontWithName:@"arial" size:20];
button.titleLabel.textColor = [UIColor colorWithRed:19/255.0f green:73/255.0f blue:17/255.0f alpha:1];
除了设置textColor
之外,一切都有效。有什么想法吗?
答案 0 :(得分:1)
试试这个。
[button.titleLabel setFont:[UIFont fontWithName:@"arial" size:20]];
[button setTitleColor:[UIColor colorWithRed:19/255.0f green:73/255.0f blue:17/255.0f alpha:1] forState:UIControlStateNormal];
答案 1 :(得分:1)
[button setTitleColor:[UIColor colorWithRed:19/255.0f green:73/255.0f blue:17/255.0f alpha:1] forState:UIControlStateNormal];