Search code examples
iosswiftswiftuiuikit

UINavigation bar appearance tint does not work in iOS 16


I am using SwiftUI and currently setting the tint color of my navigation bar back button globally using:

UINavigationBar.appearance().tintColor = .black

After upgrading to Xcode 14 and building for an iOS 16 simulator, I have noticed that the tint that I set is now being ignored and defaulting to the system blue tint color.

I have discovered that using this approach does get it to look as expected:

let image = UIImage(systemName: "chevron.backward")?.withTintColor(.black, renderingMode: .alwaysOriginal)
appearance.setBackIndicatorImage(image, transitionMaskImage: image)

However, I am curious if there are any more elegant ways of restoring the ability to control the tint globally in iOS 16


Solution

  • For SwiftUI in iOS 16, to globally set the tint color of the navigation bar back button, configure the AccentColor in Assets.xcassets. Configure AccentColor in Xcode 14