Re: Can't keep disabled UIBarButtonItem text white
Re: Can't keep disabled UIBarButtonItem text white
- Subject: Re: Can't keep disabled UIBarButtonItem text white
- From: Rick Aurbach <email@hidden>
- Date: Thu, 11 Jul 2013 11:54:07 -0400
- Acceptlanguage: en-US
- Thread-topic: Can't keep disabled UIBarButtonItem text white
Hmmm.
Okay, thinking out loud here.
I presume that the only significant difference between implementing these UIBarButtonItems initially and the remove/re-add sequences is that the view is already visible when you re-add them. (I.e., if you setTitleTextAttributes:forState: in viewWillAppear:, then the view has not yet been drawn…)
I've seen some situations before which seem like they might be analogous. In those cases, there was some sort of animation or other asynchronous behavior going on. If this is happening in your case, then your setTitleTextAttributes:forState: call (on re-adding the UIBarButtonItem) might be happening too early.
Support you try this: add the UIBarButtonItem in it's enabled state. Then in a dispatch_after (or however you prefer to implement a deferred execution block), call setTitleTextAttribute:forState: for the disabled state and then disable the control. This idea here is for the text attribute for the disabled state to be set after any animations, etc. have completed.
On Jul 10, 2013, at 6:10 PM, Rick Mann <email@hidden> wrote:
>
> On Jul 10, 2013, at 16:07 , Rick Aurbach <email@hidden> wrote:
>
>> Well, since a UIBarButtonItem is a UIBarItem, you might try explicitly using the UIBarItem method setTitleTextAttributes:forState:, specifying the disabled state. (You'll need to do this in code (such as viewWillAppear:), since IB doesn't disclose the information. I'm guessing here, but my guess is that grayed text is the default text attribute for the disabled state, unless explicitly overwritten.
>
> Sorry if I wasn't clear in the original post. This is exactly what I do, and has served me well, until I started removing and re-adding the items to the toolbar so that I could hide them when not applicable.
>
> --
> Rick
>
>
>
Cheers,
Rick Aurbach
Aurbach & Associates, Inc.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden