用UIViewAnimation实现动画,代码如下:
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView: scrollView cache:YES];
//还有这几种动画 : UIViewAnimationTransitionFlipFromLeft,UIViewAnimationTransitionCurlUp,UIViewAnimationTransitionCurlDown
[scrollView bringSubviewToFront:[scrollView viewWithTag:selectedIndex]];[UIView commitAnimations];
用CATransition实现动画,代码如下:
CATransition *animation = [CATransition animation];
animation.duration = 1.0;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionMoveIn;//还有这几种动画:kCATransitionPush,kCATransitionReveal,kCATransitionFade
animation.subtype = kCATransitionFromRight;//移动方向
[self.view.layer addAnimation:animation forKey:@"animation"];