gpt4 book ai didi

iOS 在整个应用程序中更改 NavigationBar 外观

转载 作者:行者123 更新时间:2023-12-01 15:58:56 27 4
gpt4 key购买 nike

我的 Storyboard中有多个 UINavigationController。由于我使用的是 tabbarcontroller,因此每个选项卡项都在其 ViewController 之前嵌入了自己的 UINavigationController。

我想同时设计所有这些样式。我尝试过的工作将转到 ViewControllers ViewWillAppear方法并添加以下行:

UINavigationBar *nav = self.navigationController.navigationBar;
nav.barStyle = UIBarStyleBlack;
nav.tintColor = [UIColor blackColor];
nav.translucent = NO;

但是我必须为每个选项卡项和每个 ViewController 执行此操作。

此外,在 AppDelegate 中执行以下操作也不起作用:
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTranslucent:NO];

具体来说,我很好奇为什么使用外观代理不起作用。我是新手,所以如果您提供涉及自定义 UINavigationController 或设置委托(delegate)的解决方案,请详细说明。谢谢!

最佳答案

在您的代码中也添加这一行:

[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

关于iOS 在整个应用程序中更改 NavigationBar 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32666345/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com