CATransition 的簡單用法
//引進CATransition 時要添加包“QuartzCore.framework”,然后引進“#import <QuartzCore/QuartzCore.h>”
CATransition *animation = [CATransition animation];
animation.duration = 0.6 ;
//動畫的切換時間速度
animation.timingFunction = [CAMediaTimingFunction functionWithName:@"easeInEaseOut"];
//動畫切換的方式
/*1.kCATransitionMoveIn 新的視圖把舊的視圖掩蓋
*2.kCATransitionPush 舊的視圖移走,新的視圖移進來
*3.kCATransitionFade 逐漸消失,相當於調整透明度,除了這沒有方向,其他的都有
*4.kCATransitionReveal 舊的視圖移走,顯示出新的視圖
*/
// animation.type = kCATransitionReveal;
//這類是API引入的,在蘋果官網是不會承認的,所以不建議使用
/*1.animation.type = @"cube"; //立方體效果
*2.animation.type = @"suckEffect";//猶如一塊布被抽走
*3. animation.type = @"oglFlip"; //上下翻轉效果
*4. animation.type = @"rippleEffect"; //滴水效果
*5. animation.type = @"pageCurl"; //向左翻頁
*6.animation.type = @"pageUnCurl"; //向下翻頁
*/
animation.type = @"pageUnCurl";
animation.subtype =kCATransitionFromRight ;
//視圖上加載動畫
[self.myView.layer addAnimation:animation forKey:@"animationForKey"];
[self.myView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
//用來設置設置UINavigation
// CATransition *transitionAnimation = [CATransition animation];
// transitionAnimation.duration = 0.5;
// transitionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:@"easeInEaseOut"];
// transitionAnimation.type = kCATransitionMoveIn;
//
// transitionAnimation.subtype = kCATransitionFromTop;
// [self.navigationController.view.layer addAnimation:transitionAnimation forKey:@"test" ];
//
// UIViewController *viewVC = [[UIViewController alloc] init];
// [self.navigationController pushViewController:viewVC animated:NO];