自从我将 Xcode 更新到版本 11/将我的设备更新到 iOS 13 后,在使用大标题时,我的导航栏背景颜色更改为黑色: large titles
奇怪的是,常规标题不会发生这种情况: regular titles
我已经强制使用浅色模式(因为我还没有将我的资源更新为深色模式)并检查了所有可用的界面选项。将导航栏背景颜色设置为白色时,状态栏仍然保持黑色 - 我在这里做错了什么? settings
预先感谢您的帮助。
最佳答案
在 iOS 13
及更高版本中,默认情况下,大标题导航栏不包含背景 Material 或阴影。此外,当人们开始滚动内容时,大标题会转换为标准标题
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .purple
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().barTintColor = .purple
UINavigationBar.appearance().isTranslucent = false
}
您也可以引用下面的解决方案
In iOS13 the status bar background colour is different from the navigation bar in large text mode
关于ios - iOS13/Xcode 11 上的大标题导航栏为黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58303681/