添加coreGraphics.framework框架 在CATransitionAnimation.h文件裡面引入-- #import <QuartzCore/QuartzCore.h> @interface CATransitionAnimation : UIViewController //用CATransition重寫viewControlller的push方法--1 -(void)customPushViewControllerWithAnimation:(UIViewController *)viewController; 在CATransitionAnimation.m文件裡面寫方法 //用CATransition重寫viewControlller的push方法-- -(void)customPushViewControllerWithAnimation:(UIViewController *)viewController{ CATransition *transition=[CATransition animation]; transition.duration=0.3f;//控制跳轉快慢-- transition.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];//用淡出淡入的方法 transition.type=kCATransitionPush;//用push方法 transition.removedOnCompletion=YES; transition.subtype=kCATransitionFromRight;//從右邊開始推 [viewController.view.layer addAnimation:transition forKey:@"transition"]; [self presentViewController:viewController animated:NO completion:^{}]; } 在運用文件裡面繼承此類-- @interface ViewController : CATransitionAnimation 然後直接在文件裡面引用此方法--
當上一個頁面跳轉的本頁面時: nextPAGEViewcontroller *newpage=[[nextPAGEViewcontroller alloc] init]; UINavigationController *NAC=[[UINavigationController alloc]initWithRootViewController:newpage]; NAC.navigationBarHidden=YES; 在下一個頁面直接調用navigation跳轉方法-- [self.navigationController pushViewController:viewController animated:YES];