I've not found on stackoverflow a modern solution how to make a Safari-style back button for UIBarButtonItem. Is there a simple and elegant way to implement a back button as it is in Safari?

If you are targeting iOS13 and above, you can use the built-in SF Symbols library provided by Apple.
The chevron.left image is used for the Safari back button.
let chevronLeft = UIImage(systemName: "chevron.left")
let backButton = UIBarButtonItem(image: chevronLeft, style: .plain, target: webView, action: #selector(webView!.goBack))
These icons also come in nine weights from ultralight to black, which can be applied like this.
let chevronLeft = UIImage(systemName: "chevron.left", withConfiguration: UIImage.SymbolConfiguration(weight: .thin))
More information is available from Apple here: SF Symbols
I have found solution. The best way is to find back button image on web and use this code:
let backIcon = UIImage(named: "backIcon")
let backButton = UIBarButtonItem(image: backIcon, style: .plain, target: webView, action: #selector(webView!.goBack))
For example:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With