【发布时间】:2021-11-16 22:32:15
【问题描述】:
今天我刚刚将我的 Xcode 更新到版本 13,发现我的项目的所有导航栏和标签栏都变黑了,我没有更改任何设置,我的项目在 Xcode 12 上运行良好,我已经切换到light模式,我找不到恢复旧外观的方法。
【问题讨论】:
标签: swift xcode storyboard ios15
今天我刚刚将我的 Xcode 更新到版本 13,发现我的项目的所有导航栏和标签栏都变黑了,我没有更改任何设置,我的项目在 Xcode 12 上运行良好,我已经切换到light模式,我找不到恢复旧外观的方法。
【问题讨论】:
标签: swift xcode storyboard ios15
应用以下代码来更新导航栏的外观。如果您希望它成为整个应用程序的外观,可以在 AppDelegate 中完成。
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: .black]
appearance.backgroundColor = .white
// Default portrait view
UINavigationBar.appearance().standardAppearance = appearance
// There are other appearances you could apply it to as well...
// UINavigationBar.appearance().scrollEdgeAppearance = appearance
// UINavigationBar.appearance().compactAppearance = appearance
【讨论】:
像这样:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .red
appearance.titleTextAttributes = [.font:
UIFont.boldSystemFont(ofSize: 20.0),
.foregroundColor: UIColor.white]
// Customizing our navigation bar
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance
我写了一篇关于它的新文章。
https://medium.com/@eduardosanti/uinavigationbar-is-black-on-ios-15-44e7852ea6f7
【讨论】: