Reputation: 350
i am trying to make a swipe back animation in my App. It is working completely fine, but there are two problems I have.
The First one is, that the back swipe is working on the complete page and not only on the left side of my display.
And the second questions is, how can I have this normal back swipe animation. In my App it directly pops up.
At the moment I am only using ViewController and to switch between them I use a button with perform segue. But to get back to the pervious page I would like to use this default swipe back animation Apple is having.
Upvotes: 0
Views: 676
Reputation: 714
Well there are multiple things happening.
the best way to handle this is to embed your first view controller inside UINavigationViewController
. You can then push your second view controller and so you will get that Apple back-animation
for free.
if you don't want to use NavigationController, you can at least replace that swipe recognizer with UIScreenEdgePanGestureRecognizer
, so it will trigger only near the edges of screen. But it will still just pop instantly. You can't easily replicate that back animation... you'd need to use custom transition with
UIViewControllerTransitioningDelegate
. And that's not easy.
My advice: learn more about UINavigationController
and use it.
Upvotes: 1