iOS 14 & SwiftUI: how to customize back button's image?

Hello!

In the hope to find help here, I'm posting my question: How to customize back button's image?. I know that the short answer would be "use UIKit", but I think SwiftUI is fantastic and I want to stick with it. I tried with UIAppearance, but it doesn't work at all.

Code Block
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
...
}
}
init() {
...
UINavigationBar.appearance().backIndicatorImage = UIImage(named: "arrow.left.circle")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(named: "arrow.left.circle")
}
}

Try using:

Code Block swift
.navigationBarItems(leading: {
Button(action: {
print(">>>>tapped!!!!!")
}) {
HStack {
Image(systemName: "arrow.2.circlepath")
.imageScale(.large)
Text("Button")
}
}
})

You can replace the HStack with a VStack.
Or get fancy and try the new Label with both text and image.
See https://developer.apple.com/documentation/swiftui/navigationview/navigationbaritems(leading:) for more details.
Also. navigationBarItems and some other navigation bar functions don't exist for macOS.

iOS 14 & SwiftUI: how to customize back button's image?
 
 
Q