UIBarButtonItem enabled state color wrong

We have not been able to reliably recreate this situation, but sometimes our UIBarbuttonItems (in a UIToolbar) appear to be disabled - i.e., it has a "greyed out" appearance. The buttons ARE enabled - if you tap them their action is invoked.


Has anyone seen this behavior?

Got the same problem.

Any solutions found?


Button changes to dimmed state when performing segue, but wan't change back but is still active... 😕

Same issue here - as soon as a segue is performed using a UIBarButtonItem (and later returning to the segue source), the button is dimmed out / gray - but is usable / hittable.

I am having the same issue. Has anyone found a resolution?

The only workaround I could come with that worked reliably was to first set the barButton.isEnabled = false before changing it to enabled (barButton.isEnabled = true - or whatever logic you need).

I have the same problem, but it is not limited to segues. When I press the button it is "grayed out" or "dimmed". The select action triggers when I release it (touch up event). This is an Edit (and in another case a Save) button, so I remove the button item and put it back later when editing is done. But the visible state is then dimmed, although it is enabled. This ONLY happens with the DEFAULT tint !


The proposed disable/enable workaround works for me too. And the problem also goes away if I set another tint color than "default" in Interface Builder. (Even without the disable/enable workaround.) With this other tint the button is still dimmed when selected, but it reverts to the correct visible state again by itself.

I am also facing the same issue. I tried below code


override func viewWillAppear(_ animated: Bool) {

super.viewWillAppear(animated)

favoriteButton.isEnabled = false

favoriteButton.isEnabled = true

}


I don't know is it the right solution or not. But, it solves my problem.

Which IOS version ? Which XCode version ?


Did you file a bug report for this ?

I tried the above solutions and even using UIBarItem's setTitleAttributes for state, but none of them worked consistently for me.
As a last effort, I set the tintColor on the UIBarButtonItem:

Code Block
let isEnabled = <computed property>
myBarButtonItem.isEnabled = isEnabled
myBarButtonItem.tintColor = isEnabled ? UIColor.systemBlue : UIColor.systemGray


Had the same issue and setting tintColor at the same time with isEnabled as @dferrero propesing helped me. Thanks, it should be marked as proper answer :)

Actually title color changes from fully dimmed disabled color to slightly a little less dimmed when setting enabled to true and then becomes normal (proper enabled color) when you hit it or toggling enabled property again.

P.S. This problem doesn't reproducing at iOS 14 but does at iOS 13.

UIBarButtonItem enabled state color wrong
 
 
Q