6

I have a strange visual bug in my app that only applies to iOS 13 running from an Xcode 11 build. I have a table view embedded in a Navigation Controller with the default tint color set to my app's primary orange color. On iOS12, when you cancel the search action, you are presented with a back button that follows the global nav controller tint of primary orange. This is the expected behavior. Image shown below:Orange Back Arrow in iOS12

However, this same code in iOS13 produces a system default BLUE back arrow, as shown below:

enter image description here

I have tried EVERYTHING to try and override that blue back button, including creating a custom Bar Button Item with a custom action, but that is way too messy and I want to just simply override the tint color. I've tried the obvious searchController.searchBar.tintColor = UIColor(named:"Primary") where searchController is my UISearchController, and I have tried to override the self.navigationController tint color. I've tried accessing the SearchBar natively, like this: UISearchBar.appearance().tintColor = UIColor(named:"Primary"), but still no luck. I've tried everything else I can think of in the IB, but I can not figure out how to reach this back button's tint color. Can anybody help?

eResourcesInc
  • 948
  • 1
  • 9
  • 17

4 Answers4

2

The only way I found so far to get this fix on iOS13.1 is to iterate through the subviews in the navigation bar and manually modified the tintColor.

None of the new UINavigationBarAppearance methods looks like they fix the problem. If you modified the backButtonAppearance in UINavigationBarAppearance I have been able to fix the title in back button but I haven't found a way to fix the image (<).

agy
  • 2,804
  • 2
  • 15
  • 22
0

try this

override func viewWillAppear(_ animated: Bool) {
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
        self.navigationItem.backBarButtonItem?.tintColor = .blue
}

Fetrindade
  • 11
  • 5
  • Nothing. I put that in viewWillAppear, and then I tried in viewDidLoad both before and after I attached my searchController, and it has no effect. – eResourcesInc Oct 14 '19 at 20:44
  • 3
    This seems to be a bug in iOS13.1, you can try with any of the apps from Apple and you will get the same behavior. For example if you try the Notes app you will see the same behavior. – agy Oct 15 '19 at 00:31
  • Oh wow, you’re right. Even first party Apple apps exhibit this behavior. What a joke. How can this stuff make it through months of testing and not get fixed? Ridiculous. – eResourcesInc Oct 15 '19 at 00:34
0

In iOS 13 there are few new appearance types for the navigation bar. When you want to customize navigation bar which associated with a large title or any kind of scroll view just setup appearance parameters for .scrollEdgeAppearance

if #available(iOS 13.0, *) {
        let standartAppearence = UINavigationBarAppearance()
        standartAppearence.configureWithDefaultBackground()

        // Your configuration

        UINavigationBar.appearance().scrollEdgeAppearance = standartAppearence
}
Dmitry Kuleshov
  • 571
  • 4
  • 12
0

It turns out that this was an XCode/Swift bug only affecting iOS 13.1. It should not be something that you have to account for in code, since only a very small portion of the user base is still on 13.1.

eResourcesInc
  • 948
  • 1
  • 9
  • 17