Reputation: 2484
I would like to create the same effect as the native function to come back to a previous view (but with a specific button).
I tried to code this:
// Swipe to go back
let backSwipe = UISwipeGestureRecognizer(target: self, action: #selector(self.back(_:)))
backSwipe.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(backSwipe)
In fact, this code works! But it's not as smooth as the native function. This code changes comeback to the previous view when we scroll maybe 1/3 of the current width's view. However, in the native function we can hold the swipe gesture.
Do you have any idea about how I can do that?
Upvotes: 1
Views: 692
Reputation: 855
A swipe transition like the one you're talking about would have to be custom. Unless you're looking to specifically learn how to implement that functionality I'd say it's probably ok to use a library.
Check out this cocoapod here. It's a pod that helps with the building of transition animations.
Upvotes: 2