2015-08-03 2 views
1

У меня есть простая панель инструментов на моем экране. Эта панель инструментов имеет два элемента, которые являются кнопками. Первый должен быть черным, а второй - синим. Уже изменили свой цвет кода и раскадровки, но когда я запускаю два черных приложения. Как изменить цвет только на второй элемент?change BOTTOM элементы панели инструментов цвет

это моя панель инструментов;

enter image description here

это мой код:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.deviceImages.delegate = self; 
    self.deviceImages.dataSource = self; 
    [self.rigthToolbarItem setTintColor:[UIColor colorWithRed:82/255.0 green:157/255.0 blue:230/255.0 alpha:1.0]]; 
} 

ответ

0

Решение 1:

В принципе, вы должны создать UIButton, настроить его, как вы хотите, а затем инициализировать панель Button Item с UIButton как пользовательский вид. как:

UIButton *button = [UIButton buttonWithType:....]; 
...(customize your button)... 

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:button]; 

или

Решение 2:

Чтобы изменить цвет заголовка: iOS7:

UIBarButtonItem *button = 
[[UIBarButtonItem alloc] initWithTitle:@"Title" 
            style:UIBarButtonItemStyleBordered 
           target:nil 
           action:nil]; 
[button setTitleTextAttributes: 
      [NSDictionary dictionaryWithObjectsAndKeys: 
       [UIColor redColor], NSForegroundColorAttributeName,nil] 
              forState:UIControlStateNormal]; 

and prior iOS7: 

UIBarButtonItem *button = 
    [[UIBarButtonItem alloc] initWithTitle:@"Title" 
            style:UIBarButtonItemStyleBordered 
            target:nil 
            action:nil]; 
[button setTitleTextAttributes: 
      [NSDictionary dictionaryWithObjectsAndKeys: 
       [UIColor redColor], UITextAttributeTextColor,nil] 
            forState:UIControlStateNormal]; 

Надеется, что это помогло бы выяснить решение ваш вопрос.

Смежные вопросы