iOS 13.4 上未更改 barTintColor UINavigationBar

Unchanged barTintColor UINavigationBar on iOS 13.4

在 iOS 13.4 上将 Xcode 升级到版本 11.4 (11E146) 后,barTintColor 仅通过情节提要发生变化。在代码中,更改被忽略。

self.navigationController.navigationBar.barTintColor = UIColor.redColor;

标题颜色也有问题。

已在 Xcode 11.4.1 中修复:

我遇到了同样的问题,为我解决的问题是:

在故事板上,将导航控制器的 "Bar Tint" 更改为其 "Default" 值,然后在您的代码中,您可以像往常一样更改它。

    // For the navigation bar
    navigationController?.navigationBar.barTintColor = .red

    // For the title
    let attributes = [NSAttributedString.Key.foregroundColor: UIColor.white ]
    navigationController?.navigationBar.titleTextAttributes = attributes

我在 viewDidLoad() 中有代码

对我来说奇怪的是,它还解决了我在使用 "Status Bar" 时遇到的问题。

这是对 Xcode 为 UINavigationBar 编码这些属性的方式所做的更改 – 他们现在使用 iOS 13 中引入的 UINavigationBarAppearance API。

如果您修改 UINavigationBar 的 standardAppearance 而不是使用旧外观 API,您应该得到您正在寻找的修改。

这是 Xcode 11.4 中的错误。解决方法是升级到 Xcode 11.4.1。

发行说明中特别提到了修复:https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_1_release_notes