Search code examples
iphoneobjective-ciosios4animation

Animating UIButton background image


Is there a way to animate a UIButton background image view with a set of images?

I've managed to do so with the imageView property, but couldn't find an equivalent background property.

10x


Solution

  • To change a buttons backround image, or text for that matter - you need to change it for the particular UIControlState... i.e Highlighted, Selected, Disabled

    Use

    - (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state

    I'm not sure if you can animate them, I've never tried. If you can't animate them, then you could put a UIImageView behind a transparent button and animate the images in that instead - just a thought.