изменить цвет элементов НИЖНЕЙ панели инструментов

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

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

введите здесь описание изображения

это мой код:

- (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]];
}

person Community    schedule 03.08.2015    source источник


Ответы (1)


Решение 1.

По сути, вам нужно создать UIButton, настроить его по своему усмотрению, а затем инициализировать элемент Bar Button с помощью UIButton в качестве пользовательского представления. как:

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

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

or

Решение 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];

Надеюсь, это поможет найти решение вашего вопроса.

person Niraj    schedule 03.08.2015