导航栏和标签栏在 iOS15 Xcode 13 时变黑
Navigation bar and tab bar turned black on iOS15 Xcode 13
今天我刚刚将我的 Xcode 更新到版本 13,发现我项目的所有导航栏和标签栏都变黑了,我没有更改任何设置,我的项目在 Xcode 12,我已经把它切换到灯光模式了,我找不到办法恢复到原来的样子。
应用以下代码更新导航栏的外观。如果您希望它成为整个应用程序的外观,可以在 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
只需在属性检查器中选中“半透明”即可。
今天我刚刚将我的 Xcode 更新到版本 13,发现我项目的所有导航栏和标签栏都变黑了,我没有更改任何设置,我的项目在 Xcode 12,我已经把它切换到灯光模式了,我找不到办法恢复到原来的样子。
应用以下代码更新导航栏的外观。如果您希望它成为整个应用程序的外观,可以在 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
只需在属性检查器中选中“半透明”即可。