The back button of a navigation view is typically blue by default and uses a chevron icon to indicate “Back”. However, using the UINavigationBarAppearance API we can customize not only the color but also the image indicator of the back button.
Let’s see how this customization works. To change the image we can call the setBackIndicatorImage method and provide our own UIImage. In this example we will use the system image arrow.turn.up.left
The code is as follows:
navBarAppearance.setBackIndicatorImage(UIImage(systemName: "arrow.turn.up.left"), transitionMaskImage: UIImage(systemName: "arrow.turn.up.left"))
To change the Back button color, you can change it by setting the tint property as follows:
NavigationStack {
.
.
.
}
.tint(.black)
In XCode the result, with the image changed and the color changed, is the following:
1 comment