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

AlessandroDP
  • 1,477
  • 1
  • 10
  • 19
  • How about: `navigationBar.backgroundColor`. This works for me – ibrahimyilmaz Mar 25 '20 at 16:09
  • 1
    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. – Jordan Wood Mar 25 '20 at 20:26
  • I've filed a radar for this. You should do that too, so they might fix it for the next Xcode update. – Jordan Wood Mar 26 '20 at 01:42
  • 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. – J Arango Mar 26 '20 at 03:58
  • https://stackoverflow.com/questions/60856135/ios-13-4-sdk-update-navigation-bar-title-colour-is-set-to-black – NinjaDeveloper Apr 17 '20 at 17:56

3 Answers3

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

J Arango
  • 939
  • 1
  • 8
  • 21
  • I wrote that it changes only from the storyboard. From the code, the changes are ignored regardless of the value in the storyboard. – AlessandroDP Mar 26 '20 at 06:12
  • 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. – J Arango Mar 26 '20 at 06:25
  • 1
    Hm, yesterday I tried various options and nothing, but today it worked. This works if barTintColor is set to the default value. Oh, Apple... – AlessandroDP Mar 26 '20 at 08:26
  • 1
    Great! It really solves all the problems, including the status bar color and the navigation bar title color... Thanks! :) – Leonardo Bortolotti Mar 26 '20 at 15:39
  • I'm using XCode 11.5 and still having this issue. I use xib file instead of storyboard, how do I fix this? – Tiến Nguyễn Hữu Jul 17 '20 at 14:52
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

matt
  • 515,959
  • 87
  • 875
  • 1,141
-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.