Раскрасить UINavigationBar в iOS
-
11-09-2019 - |
Вопрос
Я раскрасил панель навигации в оранжевый цвет:
navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.88 green:0.52 blue:0.27 alpha:1];
Все работает нормально, каждая кнопка такая же оранжевая, как и полоса, но когда ic доходит до меню настраиваемого правого пункта, он показывает его синим.Это скриншот: http://img146.imageshack.us/img146/5605/schermata20091202a14565.png
и это код для правых кнопок:
UIView *container = [[UIView alloc] init];
UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addGadget:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"less.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setEditing:)];
[buttons addObject:bi];
[bi release];
[tools setItems:buttons animated:NO];
[buttons release];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
Как сделать все оранжевым?
Решение
Вам следует установить tintColor
принадлежащий UIToolbar
объект должен быть таким же, как и объект UINavigationBar
.
Обратите внимание, что UIToolbar
это не то же самое, что UINavigationBar
, градиент/цвет фона немного отличается.Попробуйте установить фоновый цвет панели UIToolbar на +[UIColor clearColor]
Кроме того, вам, вероятно, даже не понадобится контейнер UIView
, с UIToolbar
является подклассом UIView
, поэтому вы можете использовать его как customView отдельно.