ios - Setting a background image for highlighted state removes automatic highlight -
i'm implementing checkbox subclass of uibutton. there 2 background images (on/off) , 4 conceptual states:
on
- on image / not highlightedoff
- off image / not highlightedon & pressed
- on image / highlightedoff & pressed
- off image / highlighted
if set background images on , off (uicontrolstatenormal
, uicontrolstateselected
), button gets highlighted when held.
however, when on & pressed
, uses off image (as expected, because state uicontrolstateselected | uicontrolstatehighlighted
, uses normal state image)
so set background image uicontrolstateselected | uicontrolstatehighlighted
on image, programmatic highlight disabled - assume because if set specific background image state logic want override highlight.
i don't want use third image, possible set background image uicontrolstateselected | uicontrolstatehighlighted
, still have programmatic highlight applied?
i'm calling [self setadjustsimagewhenhighlighted:yes];
after setting background image.
i guess using uibutton
type not "custom" e.g. "rounded rect". in case setting background image can have unexpected side effects, see earlier question.
suggest change button type "custom". of course have define attributes own.
Comments
Post a Comment