Fading an Image into Another
My Pollen project required that I be able to have an image, and fade it into another image. Other projects since then have also had similar requirements. The effect is very nice, and the great thing is that the code is really quite simple. Just have two images, and do an animation from one to the other. I like have one image always being the active one (when not animating), so that’s how I structured the code below. I assume you have two UIImageView’s set up named mFrontView and mBackView.
UIImage *oldImg = mFrontView.image;
if ( newImg != oldImg )
{
[mBackView setImage:mFrontView.image];
mFrontView.alpha = 0;
mBackView.alpha = 1;
[mFrontView setImage:newImg];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
mFrontView.alpha = 1;
mBackView.alpha = 0;
[UIView commitAnimations];
}