Question

Our designer asked me to use specific color for text of disabled UIBarButtonItems. That code I've used to implement this:

NSDictionary* textAttributes = [NSDictionary dictionaryWithObject: [UIColor blueColor]
                                                           forKey: UITextAttributeTextColor];

[[UIBarButtonItem appearance] setTitleTextAttributes: textAttributes
                                            forState: UIControlStateDisabled];

But it doesn't changed text attributes.

I've tried this code with Normal state, tried to chage background for UIControlStateDisabled buttons with setBackgroundImage and all thouse experiments works perfectly. But this single combination: setTitleTextAttributes and UIControlStateDisabled doesn't do anything.

Google didn't give me any relevant answer about that specific combination.

Does anybody know other way to change color of disabled UIBarButtonItem or way to make setTitleTextAttributes work for diabled items?

Était-ce utile?

La solution

You have to set it for both control state Normal and Disabled.

(2015-11-18 -- As of iOS 9.1 you must still set both.)

Autres conseils

It's working fine for me with iOS 5.1. Perhaps it was a 5.0 bug.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top