NavigationBar Back Button Color iOS 16

I just noticed, that iOS 16 is using the accent color for the navigation bar back button. (SwiftUI) When running my app on iOS 15 devices it's white.

Is there a way to change that behavior? I want to have another accent color than white.

You can set accentColor on the NavigationStack

You can try this:

  let appearance = UINavigationBarAppearance()

  appearance.configureWithOpaqueBackground() // configure
   

  let backItemAppearance = UIBarButtonItemAppearance()
  backItemAppearance.normal.titleTextAttributes = [.foregroundColor : UIColor.white] // fix text color
  appearance.backButtonAppearance = backItemAppearance
   
  let image = UIImage(systemName: "chevron.backward")?.withTintColor(.white, renderingMode: .alwaysOriginal) // fix indicator color
  appearance.setBackIndicatorImage(image, transitionMaskImage: image)
   
  UINavigationBar.appearance().tintColor = .white // probably not needed
   
  UINavigationBar.appearance().standardAppearance = appearance
  UINavigationBar.appearance().scrollEdgeAppearance = appearance
  UINavigationBar.appearance().compactAppearance = appearance
  UINavigationBar.appearance().compactScrollEdgeAppearance = appearance

Sadly this method no longer works. It was working great in iOS 15 and below, but something must have changed.

In iOS 16 when you are using NavigationStack, you might use the .tint(YourColorHere):

NavigationStack {
// UI components here
}
.tint(YourColorHere)

UINavigationBar.appearance().barTintColor = UIColor(.black)

NavigationBar Back Button Color iOS 16
 
 
Q