Alex
Alex

Reputation: 23

Custom UIBarButtonItem not working with appearance

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)

Upvotes: 2

Views: 283

Answers (1)

hessam
hessam

Reputation: 432

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

Upvotes: 1

Related Questions