Is it possible to change the Direction of ViewContoller Pop animation.
Right now when we push VC at the time it shows animation Slide Left-to-Right and on Pop Right-to-Left.
But i want animation Slide Left-to-Right on Pop VC.
I have tried to use UIViewAnimationTransition
.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
But it doesn't have the animation i need which is Slide Left-to-Right. This is the animation i get
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
Cheers, here is the swift 3.0 ~ 4.0 version.
let transition = CATransition()
transition.duration = 0.4
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.navigationController?.view.layer.add(transition, forKey: kCATransition)
self.navigationController?.popViewController(animated: false)
I have used following code..
Add this in didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//This line of code needed so you will not see the back window when its pop, match it with your app design.
self.window.backgroundColor = [UIColor whiteColor];
return YES;
}
Where your POP code add this code,
CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];
Check the result in this GIF,
http://www.giphy.com/gifs/l2YSeBELE1phMEd5S
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With