因为我将Xcode更新到版本11 /我的设备更新到iOS 13,所以在使用大标题时,导航栏的背景颜色更改为黑色:large titles
奇怪的是,常规标题不会发生这种情况:regular titles
我已经强制进入亮模式(因为我还没有为暗模式更新资产),并检查了所有可用的界面选项。将导航栏的背景色设置为白色时,状态栏仍保持黑色-我在这里做错了什么?settings
感谢您的帮助。
iOS 13
及更高版本中,默认情况下,大标题导航栏不包含背景材料或阴影。另外,随着人们开始滚动内容,大型标题会转换为标准标题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