Try the search, it's linked to some great forums

Thursday, July 7, 2011

Animation block with completion code

This method allow you to string together animation features;
-(void)photoLoopAnimation
{
    // FADE block animation method - THIS contains the basic animation features   
    [UIView animateWithDuration:1.2 delay:delaySeconds
                        options:UIViewAnimationOptionAllowUserInteraction       
                     animations:^{
                         viewTop.alpha = 0.0;
                         viewBottom.alpha = 1.0;
                     }
                     completion:^(BOOL finished) {       // remove both views & loop to slideShowSwitch
                         [viewTop removeFromSuperview]; 
                         [viewBottom removeFromSuperview];
                         [viewTop release];
                         [viewBottom release];
                         [self photoLoop];
                     }];   
}

The completion: parameter allows you to branch to other functions ONCE the animation is complete.  The animation block runs on a background thread, and does NOT pause execution of the rest of the code