ios - UIBarButtonItem does not show disabled state titleTextAttributes -
i'm trying set disabled textattributes
on uibarbuttonitem
in uitoolbar
.
i create item so:
nsdictionary *enabledattrs = @{ nsfontattributename : font, nsforegroundcolorattributename : color }; nsdictionary *disabledattrs = @{ nsfontattributename : font, nsforegroundcolorattributename : [uicolor graycolor] }; [item settitletextattributes:enabledattrs forstate:uicontrolstatenormal]; [item settitletextattributes:disabledattrs forstate:uicontrolstatedisabled];
however, when set item.enabled = no
, button disabled (it not fire action) not honor titletextattributes
-- still appears in normal state. why?
create uibutton , wrap uibarbutton,i think should work.
uibutton *uibutton = [[uibutton alloc] init]; [uibutton settitlecolor: color1 forstate: uicontrolstatenormal]; [uibutton settitlecolor: color2 forstate: uicontrolstatedisabled]; uibarbuttonitem *uibarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:uibutton];
Comments
Post a Comment