In ios 13, Apple introduced the new UINavigationBarAppearance proxy object to set the navigation bar appearance. I've been able to set almost everything I needed except one small thing. The back button's arrow is always rendered with blue tint color and I have no idea how to set it to the color I want. I am using the old [[UINavigationBar appearance] setTintColor:]
way, but I think there has to be some way to do it with the UINavigationBarAppearance objects API. Anybody has any idea how?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With