这是我目前用于动画的代码,它在默认的“推送”功能的相反方向“推”:
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[sourceViewController.navigationController.view.layer addAnimation:animation
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
虽然与默认的推送动画略有不同。它在离开屏幕之前逐渐变黑,而标准按钮在被推离屏幕之前仅稍微渐渐变为灰色。
我想使它与推动动画相同,但方向相反。