ISHHoverBar icon indicating copy to clipboard operation
ISHHoverBar copied to clipboard

Unable to dynamically set the image of a UIBarButtonItem

Open Sweeper777 opened this issue 9 years ago • 2 comments

I added a UIBarButtonItem to a hover bar. In the UIBarButtonItem's IBAction method, I changed the image of the UIBarButtonItem:

sender.image = UIImage(...)

But the image doesn't change when I tap on the UIBarButtonItem!

I know I can do this as a workaround:

bar.items = [sender]

But can you fix this bug?

Sweeper777 avatar Aug 25 '16 09:08 Sweeper777

That is definetly something that we will need to fix. The underlying reason is that we cannot use a barbutton item directly and instead create a UIButton from it. As a work-around you should simply set the items array again.

felixLam avatar Aug 25 '16 10:08 felixLam

To really fix this we would need to listen to changes on the image property of the barbutton item (KVO).

felixLam avatar Aug 25 '16 10:08 felixLam