I'm implementing a checkbox subclass of a UIButton. There are 2 background images (on/off) and 4 conceptual states:
on- on image / not highlightedoff- off image / not highlightedon & pressed- on image / highlightedoff & pressed- off image / highlighted
If I set background images for only on and off (UIControlStateNormal and UIControlStateSelected), the button gets highlighted when held.
However, when on & pressed, it uses the off image (as expected, because the state is UIControlStateSelected | UIControlStateHighlighted, so it uses the normal state image)
So I set the background image for UIControlStateSelected | UIControlStateHighlighted to be the on image, but now the programmatic highlight is disabled - I assume because if you set a specific background image for that state the logic is you probably want to override the highlight.
I don't want to use a third image, is it possible to set a background image for UIControlStateSelected | UIControlStateHighlighted and still have the programmatic highlight get applied?
I'm already calling [self setAdjustsImageWhenHighlighted:YES]; after setting the background image.