Animating UIButton Images
I would like to give a UIButton in my application a continuous "ripple" effect as it animates a series of images and then reverts back through those same images. I found examples of UIImageViews using the animationImages property, but all I found for UIButtons is animation changing their alpha.
UIView's setAnimationRepeatAutoreverses method is what I want for a loop, but I don't understand how to use an array of images in an animation block for a UIButton. Is this possible or is the NSTimer / setImage approach recommended? Any examples are greatly appreciated.
source to share
While the subview method works, the easiest is to simply set the animationImages property on the UVIutton of the imageView. From the docs:
Although the [imageView] property is read-only, its own properties are read / written. using these properties to customize the appearance and browsing behavior of buttons.
For example:
self.pulsingButton.imageView.animationImages =
[NSArray arrayWithObjects:[UIImage imageNamed:@"button1.png"],
[UIImage imageNamed:@"button2.png"],
nil];
source to share