Slowing Down Transition of Push Segue

流过昼夜 提交于 2019-12-02 20:48:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/36611847/slowing-down-transition-of-push-segue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!