Unchanged barTintColor UINavigationBar on iOS 13.4

1.6k Views Asked by At

After upgrading Xcode to Version 11.4 (11E146) on iOS 13.4 barTintColor only changes through the storyboard. In the code, changes are ignored.

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

Also a problem with the color of the title.

enter image description here

Fixed in Xcode 11.4.1: Fixed in Xcode 11.4.1

3

There are 3 best solutions below

5
On BEST ANSWER

I was having the same issue, what fixed it for me was this:

On the storyboard, for your Navigation Controller change the "Bar Tint" to its "Default" value, then on your code you can change it as you normally would.

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

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

enter image description here

I have the code in viewDidLoad()

enter image description here

Oddly enough for me, it also fixed the issue I was having with the "Status Bar".

1
On

This was a change made to how Xcode encodes these properties for UINavigationBar – they now use the UINavigationBarAppearance API introduced in iOS 13.

If you modify the UINavigationBar's standardAppearance instead of using the old appearance API you should get the modifications you are looking for.

0
On

This was a bug in Xcode 11.4. The fix is to upgrade to Xcode 11.4.1.

The fix is specifically called out in the release notes: https://developer.apple.com/documentation/xcode_release_notes/xcode_11_4_1_release_notes