UINavigationController Style

I created a UINavigationController in the code, but I want to change the 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 does not change. Help me please!

+5
source share
1 answer

I suspect this is because you are accessing the navigation controller of the navigation controller. Your navigation controller does not live in another navigation controller, so you adjust the panel style to something that is not there.

Do you want to:

navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;

You can also create a navigation controller and immediately initialize it using the root view controller, so you do not need to click it manually, for example:

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;

, fvc .

+14

All Articles