#pragma mark - Animation code block - (void)exchangeViewWithAnimation:(UIView *)view changeView:(UIView *)sView withView:(UIView *)eView animationType:(NSInteger)type { NSUInteger sv = [[view subviews] indexOfObject:sView]; NSUInteger ev = [[view subviews] indexOfObject:eView]; CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:context]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1.0]; switch (type) { case 0: [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view cache:YES]; [view exchangeSubviewAtIndex:sv withSubviewAtIndex:ev]; break; case 1: [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:view cache:YES]; [view exchangeSubviewAtIndex:sv withSubviewAtIndex:ev]; break; default: break; } [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationFinished:)]; [UIView commitAnimations]; } //动画效果执行完毕 - (void) animationFinished: (id) sender{ NSLog(@"animationFinished !"); }