i have subClass from UIBarButtonItem, when set setBackgroundImage with appearance not working, but create subClass from UIButton set image worked!.
my code:
MyCustomBarButtonItem.appearance().setBackgroundImage(UIImage(named: "back_image"), for: .normal, barMetrics: .default)
you must create subClass from UIButton
and assign to customView
property in subClass from UIBarButtonItem and set image background to custom UIButton.
for more information you can see this post: https://stackoverflow.com/a/66074112/5140621