AlessandroDP
AlessandroDP

Reputation: 1497

Unchanged barTintColor UINavigationBar on iOS 13.4

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

Upvotes: 6

Views: 1745

Answers (3)

matt
matt

Reputation: 535576

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

Upvotes: 0

David Duncan
David Duncan

Reputation: 1

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.

Upvotes: -1

J Arango
J Arango

Reputation: 951

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".

Upvotes: 10

Related Questions