开发者

UINavigationController Style

I created in code UINavigationControl开发者_JAVA百科ler, 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜