animation alpha change

Melisa D picture Melisa D · May 19, 2011 · Viewed 32.6k times · Source

I've always worked with Flash, and it's pretty easy to change the alpha values between one frame and another. Is there a way to do this in xcode 4? I'm animating a logo and I need the first png to disappear while the second one starts appearing. tnx!

Answer

nil picture nil · May 20, 2011

Alternatively to esqew's method (which is available prior to iOS 4, so you should probably use it instead if you don't plan to limit your work to just iOS 4), there is also [UIView animateWithDuration:animations:], which allows you to do the animation in a block. For example:

[UIView animateWithDuration:3.0 animations:^(void) {
    image1.alpha = 0;
    image2.alpha = 1;
}];

Fairly simple, but again, this is available only on iOS 4, so keep that in mind.