Unchanged barTintColor UINavigationBar on iOS 13.4
Asked Answered
I

3

6

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

Idiomorphic answered 25/3, 2020 at 10:50 Comment(5)
How about: navigationBar.backgroundColor. This works for meEarl
I am having the same problem. I am trying to set my background color to clear. I have had code to do this using barTintColor for years, and it now doesn't work with the new SDK in Xcode 11.4 for iOS 13 devices. backgroundColor also doesn't work.Badenpowell
I've filed a radar for this. You should do that too, so they might fix it for the next Xcode update.Badenpowell
I have spent hours trying to figure this out thinking that it was something in my code. I updated to Xcode 11.4 and it even messed up with some of my navigations bars. The same goes with the status bar won't change to "light" when navigating through the navigation bar.Bullish
#60856635Halfpenny
B
10

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

Bullish answered 26/3, 2020 at 4:20 Comment(5)
I wrote that it changes only from the storyboard. From the code, the changes are ignored regardless of the value in the storyboard.Idiomorphic
Yeah, for me this was the solution. There was a different color on the storyboard, and when I placed it back to "Default" and then set the color I wanted on the code it worked fine. I even created a "Test" project to re-check. And when there was a value on the storyboard it would not behave as expected.Bullish
Hm, yesterday I tried various options and nothing, but today it worked. This works if barTintColor is set to the default value. Oh, Apple...Idiomorphic
Great! It really solves all the problems, including the status bar color and the navigation bar title color... Thanks! :)Playgoer
I'm using XCode 11.5 and still having this issue. I use xib file instead of storyboard, how do I fix this?Toffeenosed
B
0

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

Barr answered 17/4, 2020 at 23:46 Comment(0)
P
-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.

Poco answered 17/4, 2020 at 16:37 Comment(1)
#60856635Halfpenny

© 2022 - 2024 — McMap. All rights reserved.