2014-02-12 3 views
0

У меня есть UIButton, который создается программно.Цвет текста 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. Любые идеи почему?

ответ

1
[button setTitleColor:[UIColor colorWithRed:19/255.0f green:73/255.0f blue:17/255.0f alpha:1] forState:UIControlStateNormal]; 
+0

Perfect - благодаря – RGriffiths

+0

Добро пожаловать! – plu

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]; 
Смежные вопросы