3

I have a method

- (void) swipeRight
{
[self dismissViewControllerAnimated:YES completion:nil];
}

Which I am using to dismiss the view controller when the user swipes right. I dont really like the animation that apple provides when you dismiss the view controller (page goes down) and I want to change it to a different one that apple provides, while still using the dismissViewControllerAnimated method. Can anyone help me change this?

MendyK
  • 1,643
  • 1
  • 17
  • 30

2 Answers2

3

For @Tomaž Stoiljkovič (and anyone interested in Swift 4)

    let transition = CATransition()
    transition.duration = 0.3
    transition.type = kCATransitionFade
    transition.subtype = kCATransitionFromTop

    navigationController?.view.layer.add(transition, forKey: kCATransition)
    self.dismissViewControllerAnimated(false, completion: nil)
M-P
  • 4,909
  • 3
  • 25
  • 31
mike.tihonchik
  • 6,855
  • 3
  • 32
  • 47
1

Try putting this just before your dismiss:

CATransition* transition = [CATransition animation];
        transition.duration = 0.3;
        transition.type = kCATransitionFade;
        transition.subtype = kCATransitionFromTop;

Then set animated:NO

[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self dismissViewControllerAnimated:NO completion:nil];

-- More transition types you can try:

kCATransitionFade;
kCATransitionMoveIn;
kCATransitionPush;
kCATransitionReveal;
Adama
  • 1,101
  • 8
  • 26