接下来设置动画特效,有四种特效可供选择:
[UIView setAnimationTransition:UIViewAnimationTransitio
[UIView setAnimationTransition:UIViewAnimationTransitio
[UIView setAnimationTransition:UIViewAnimationTransitio
[UIView setAnimationTransition:UIViewAnimationTransitio
之后就可以切换view了,最后执行动画:
[UIView commitAnimations];
第二类动画特效:
这类动画特效需要用到QuartzCore.framework,单击工程,点击Build Phases,找到Link Binary With Libraries,点击下面的+号,找到QuartzCore.framework添加即可。
同样,在view切换之前需要做一些设置:
然后就可以选择动画类型,大概有十二种动画:
animation.type = kCATransitionFade;
animation.type = kCATransitionPush;
animation.type = kCATransitionReveal;
animation.type = kCATransitionMoveIn;
animation.type = @"cube";
animation.type = @"suckEffect";
animation.type = @"oglFlip";
animation.type = @"rippleEffect";
animation.type = @"pageCurl";
animation.type = @"pageUnCurl";
animation.type = @"cameraIrisHollowOpen";
animation.type = @"cameraIrisHollowClose";
任选其中一种。同时也可以设置animation的subtype,用以设置动画运行的方向,如:
animation.subtype = kCATransitionFromLeft;
animation.subtype = kCATransitionFromBottom;
animation.subtype = kCATransitionFromRight;
animation.subtype = kCATransitionFromTop;
之后是切换view,最后还要添加一句代码:
[[self.view layer] addAnimation:animation forKey:@"animation"];