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.
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
Thank you for your reply! However I'm not using NavigationStacks since I need to support iOS 15 as well. Also when I change the accent color at the navigation level it changes everywhere. But I do want to have it different than white on some dialogues for example. Also this behavior is just happening when using iOS 16, on iOS 15 it looks like it's supposed to.
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