Rodrigo
Rodrigo

Reputation: 12683

Custom UIViewController Transition?

There are another custom UIViewController transition than the 4 natives iOS:

typedef enum {
    UIModalTransitionStyleCoverVertical = 0,
    UIModalTransitionStyleFlipHorizontal,
    UIModalTransitionStyleCrossDissolve,
    UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;

Any tips?

Upvotes: 3

Views: 813

Answers (1)

sooper
sooper

Reputation: 6039

You could also try CATransition, for example, the code below shows a transition where a second view pushes your current view out to the right. (Assuming this code is placed in your main view controller).

UIView *appWindow = [self.view superview];

CATransition *animation = [CATransition animation];
[animation setDuration:0.3];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[appWindow addSubview:yourSecondViewController.view];
[self.view removeFromSuperview];

[[appWindow layer] addAnimation:animation forKey:@"showSecondViewController"];

Upvotes: 2

Related Questions