大神处处有,群里特别多,效果不错,记录一下
从左往右PUSH
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
MainViewController * fc = [[MainViewController alloc]init];
fc.view.backgroundColor = [UIColor whiteColor];
[self.navigationController pushViewController:fc animated:NO];
从右往左退出
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:YES];