NavigationControllerを使わずに(もしくはNavigationControllerごと)Pushトランジションを使いたいときはCATransitionを使う。CATransitionに用意されていないものはCAAnimationで組み立てる必要がある。
#import <QuartzCore/QuartzCore.h>
も必要。
PushTransition.m
[CATransaction begin];
CGFloat duration = 0.5f;
CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
transition.duration = duration;
transition.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.11 :0.72 :0.02 :0.96]; // easing関数次第でかなり印象の違う効果が生まれる
[[UIApplication sharedApplication].keyWindow.layer addAnimation:transition forKey:@"transition"];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents]; // ユーザーの操作を止める
[CATransaction setCompletionBlock: ^ {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^ {
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
});
}];
[fromViewController presentModalViewController:toViewController animated:NO];
[CATransaction commit];