Custom UIBarButtonItem not working with appearance

Viewed 134

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)
1 Answers

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

Related