I created in code UINavigationController, but I want to change style to black translucent
FirstViewController *fvc = [[FirstViewControlelr alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] init];
navcon.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[navcon pushViewController:fvc animated:NO];
[self.window addSubview:navcon.view];
[self.window makeKeyAndVisible];
return YES;
But he doesn't change. Help me please!
A container view controller that defines a stack-based scheme for navigating hierarchical content.
The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar.
Change the Bar Style A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
The navigation item used to represent the view controller in a parent's navigation bar.
I suspect it has something to do with the fact that you're accessing a navigation controller's navigation controller. Your navigation controller doesn't live in another navigation controller, so you're setting the bar style of something that isn't there.
You want this:
navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Also you can make a navigation controller and immediately initialize it with a root view controller so you don't have to push it in manually, like this:
FirstViewController *fvc = [[FirstViewController alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:fvc];
[fvc release];
navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self.window addSubview:navcon.view];
[self.window makeKeyAndVisible];
return YES;
And yes, you forgot to release fvc
in your own code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With