UINavigationController风格

发布于 2024-10-24 22:19:29 字数 443 浏览 1 评论 0原文

我在代码中创建了UINavigationController,但我想将样式更改为黑色半透明

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;

但他没有更改。请帮助我!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶视觉 2024-10-31 22:19:29

我怀疑这与您正在访问导航控制器的导航控制器有关。您的导航控制器不在另一个导航控制器中,因此您正在设置不存在的内容的栏样式。

您想要这样:

navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;

您还可以创建一个导航控制器并立即使用根视图控制器初始化它,这样您就不必手动将其推入,如下所示:

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在你自己的代码中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文