NavBar\ Панель инструментов цвет текста кнопки?

Я использую следующий код для создания кнопок панели инструментов.... Я хотел бы изменить цвет текста на черный или еще лучше... установить фоновое изображение для цвета текста.....setBackgroundColor не будет работать.... любая помощь ценится, спасибо.

UIButton *btnEditLogin = [UIButton buttonWithType:UIButtonTypeCustom];
   [btnEditLogin setBackgroundImage:[UIImage imageNamed:@"btnPlain.png"] forState:UIControlStateNormal];
   [btnEditLogin setTitle:@"Edit Login" forState:UIControlStateNormal];
   [btnEditLogin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
   btnEditLogin.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
   [btnEditLogin.layer setCornerRadius:5.0f];
   [btnEditLogin.layer setMasksToBounds:YES];
   [btnEditLogin.layer setBorderWidth:1.0f];
   [btnEditLogin.layer setBorderColor: [[UIColor brownColor] CGColor]];
   btnEditLogin.frame=CGRectMake(0.0, 100.0, 90.0, 30.0);
   [btnEditLogin addTarget:self action:@selector(LoginBtn) forControlEvents:UIControlEventTouchUpInside];
   UIBarButtonItem *editLoginItem = [[UIBarButtonItem alloc] initWithCustomView:btnEditLogin];

2 ответа

Используйте этот код, чтобы изменить цвет текста панели инструментов.

UIBarButtonItem *barButtonAppearance = [UIBarButtonItem appearance];
[barButtonAppearance setTintColor:[UIColor redColor]];

Вы можете просто использовать атрибут titleView NavigationItem, чтобы делать то, что вам нужно. Вы можете сделать следующее:

UILabel *myLabel = [... enter all the code you want to customize the text, etc here];
self.navigationcontroller.navigationitem.titleView = myLabel;

И ты должен быть готов... если я не пойму вопрос.

Другие вопросы по тегам