IOS7 navigatinBar tintColor change in popover
Asked Answered
L

2

9

I developed iPad application. I'm opening some screens in popover with navigation controller. But I did not change navigationcontroller tint color in IOS 7. How can I change this color. thanx

enter image description here

UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:airportsSearch] autorelease];
navigationController.navigationBar.barTintColor = [UIColor blackColor];
navigationController.navigationBar.translucent = NO;
self.popOver=[[UIPopoverController alloc] initWithContentViewController:navigationController];

self.popOver.delegate                    = self;
[self.popOver setPopoverContentSize:CGSizeMake(285, 370)];

[self.popOver presentPopoverFromRect:tempButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
Leigh answered 30/9, 2013 at 13:13 Comment(4)
#18930364Osterman
@Osterman this method don't work :(Leigh
can you send me your sample code ?Osterman
There is sample code on question, thnxLeigh
A
35

The magical word here is barStyle, you need to do the following if you need it black:

navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.translucent = NO;

And if you want to change its color:

navigationController.navigationBar.barTintColor = [UIColor redColor];
navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.translucent = NO;
Acceptation answered 30/9, 2013 at 17:3 Comment(3)
@null thank you very much. I had a custom UINavigationController class where I set the same properties beside barStyle. All my navigationControllers worked fine and they have set UIBarStyleDefault in the storyboard. Only my NavigationBars inside Popovers were translucent and the barTintColor didn't change anything. Only the tintColor got set. But as soon as I set the barStyle to Black the problems were resolved!Laze
For some reason setting the barStyle to UIBarStyleBlack removes the navigation bar shadow... May be you have an advice how to fix that?Away
I think removing the translucent causes this, may this https://mcmap.net/q/73590/-how-to-hide-uinavigationbar-1px-bottom-line will help.Acceptation
V
6

Setting the NavigationBarStyle to UIBarStyleBlack also worked for me, but only via the Storyboard.

I tried

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

as well as

[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBarStyle:UIBarStyleBlack];

in the didFinishLaunchingWithOptions AppDelegate method. But nothing changed. Only changing the BarStyle of the NavigationControllers NavigationBar inside the Storyboard worked.

Vaasta answered 2/3, 2014 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.