Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIBarButtonItem appearance setTitleTextAttributes does not affects UIControlStateDisabled state

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?

like image 983
lazarev Avatar asked Jul 30 '12 08:07

lazarev


1 Answers

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.)

like image 131
Καrτhικ Avatar answered Oct 22 '22 09:10

Καrτhικ