16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CATransition

Last updated at Posted at 2012-02-07

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];                  
16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?