Search code examples
iosswiftuiviewcontrollersegueuistoryboardsegue

Slowing Down Transition of Push Segue


I was wondering if there is a way to slow down 'push segue & back' like Tinder & Snapchat does. It's like normal segue but it's somehow transiting slowly.

I normally handle push segues with setting up a Push notification on Storyboard and programatically calling the segue (clicked on NavBarItem and push segued to new UIViewController):

func settingsTapped() {
    performSegueWithIdentifier("NewsToSettings", sender: nil)
}

It there a way to

  • enable slowing down segue globally for the whole app?

  • or should I do it maually for each segue? If so, what is the appropriate way?


Solution

  • I was wondering if there is a way to slow down 'push segue & back' like Tinder & Snapchat does. It's like normal segue but it's somehow transiting slowly.

    As you've been told, you simply write a custom transition animation. Give the navigation controller a delegate and implement navigationController:animationControllerForOperation:fromViewController:toViewController:. Basically then you just supply an object that implements the UIViewControllerAnimatedTransitioning protocol. As part of that, you get to specify the animation duration.

    enable slowing down segue globally for the whole app?

    If all your navigation controllers have this same delegate, or if all the delegates supply this same UIViewControllerAnimatedTransitioning object, all push / pop transitions will use the same code and will work the same way.