gpt4 book ai didi

objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?

转载 作者:技术小花猫 更新时间:2023-10-29 10:06:25 27 4
gpt4 key购买 nike

我正在构建一个包含多个 View Controller 的应用程序:我有一个 UITabBarController,其中包含 4 个 UINavigationController。我希望所有导航栏都是我的自定义颜色,比如蓝色,我通过在我的应用程序委托(delegate)中这样做来实现:

[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];

但我还有一个特殊的 View Controller ,它有一张 map ,对于这个 View Controller ,我想使用 UIAppearance 覆盖蓝色导航栏集,使其成为黑色不透明样式。我试过在 viewDidLoad 中调用它:

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = YES;

但是没有任何反应。可以这样做还是我必须放弃 UIAppearance 并为每个 View Controller 手动设置 navigationBar 上的属性?

最佳答案

您执行此操作的方式应该有效,但事实并非如此。这确实有效:

swift 4

UINavigationBar.appearance(whenContainedInInstancesOf: [YourOtherVC.self]).tintColor = .black

Objective-C

[[UINavigationBar appearanceWhenContainedIn:[YourOtherVC class], nil] setTintColor:[UIColor blackColor]];

关于objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8459821/

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