What is the right way to set back button arrow tint in ios 13

I have a custom navigation controller setup in my app, which modifies navigationBars titleTextAttributes, tintColor and others depending on different scenarios.

Running the app on iOS 13 the backBarButtonItem arrow had default blue tint color. The view debugger showed that only the UIBarButtonItems UIImageView had this blue tint.

What I ended up doing was setting the navigationBar.tintColor twice for it to change the color...

public class MyNavigationController: UINavigationController, UINavigationControllerDelegate {

    public var preferredNavigationBarTintColor: UIColor?

    override public func viewDidLoad() {
        super.viewDidLoad()
        delegate = self
    }


    public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {

        // if you want to change color, you have to set it twice
        viewController.navigationController?.navigationBar.tintColor = .none
        viewController.navigationController?.navigationBar.tintColor = preferredNavigationBarTintColor ?? .white

        // following line removes the text from back button
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)

    }


The weirdest part when looking for solution was the inconsistent result, which makes me think its related to view life cycle and/or appearance animations or Xcode cache :)


The new way of setting the back button color of the appearance (proxy) would be:

let appearance = UINavigationBarAppearance()

// Apply the configuration option of your choice
appearance.configureWithTransparentBackground()
            
// Create button appearance, with the custom color
let buttonAppearance = UIBarButtonItemAppearance(style: .plain)
buttonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white]

// Apply button appearance
appearance.buttonAppearance = buttonAppearance

// Apply tint to the back arrow "chevron"
UINavigationBar.appearance().tintColor = UIColor.white

// Apply proxy
UINavigationBar.appearance().standardAppearance = appearance

// Perhaps you'd want to set these as well depending on your design:
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance