ios - iOS13/Xcode 11 上的大标题导航栏为黑色

标签 ios navigationbar ios13 xcode11

自从我将 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/

相关文章:

ios - 如何使用 Xamarin 在 iOS 的 NavigationController 中更改 1 个字符的标题文本颜色

html - 无法更改 CSS 导航栏高度

ios - iOS:13位置始终允许:点击“打开设置”后,它不会重定向到“应用程序设置”页面

iphone - 在表格 View 部分标题中垂直居中 UILabel 文本

ios - 创建对象的 NSMutableArray

html - 将标签添加到 Divy 侧边导航

ios - SwiftUI 的 minimumFontScale 等价物是多少?

ios - 如何在ios13中禁用pdfkits pdfview中的查找、共享、转发菜单项

ios - 如何避免小时数被标记为日历链接?

ios - 添加新的自定义 View Controller 后应用程序无法运行