If you swipe with the Swipe Gesture Recognizer on Swift3, you can only open right (right-to-left screen transition) no matter which way you swipe.Please let me know if there is a way to transition the screen from the left.
override func viewDidLoad(){
super.viewDidLoad()
// Swipe to the left
let leftSwipe=UISwipeGestureRecognizer(target:self, action:#selector(swipeAction(swipe:)))
leftSwipe.direction=UISwipeGestureRecognizerDirection.left
self.view.addGestureRecognizer (leftSwipe)
// Swipe to the right
let rightSwipe=UISwipeGestureRecognizer (target:self, action:#selector(swipeAction(swipe:)))
rightSwipe.direction=UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer (rightSwipe)
}
func swipeAction (swipe:UISwipeGestureRecognizer) {
switchswipe.direction{
case UISwipeGestureRecognizerDirection.right:
performSegue(withIdentifier: "backView", sender:self)
case UISwipeGestureRecognizerDirection.left:
performSegue(withIdentifier: "goView", sender:self)
default:
break
}
}
PageViewController enables you to implement Gesture or Animation without having to implement anything (although I'm not sure if it's appropriate for the purpose of the question).
Swipe Gesture Recognizer
has nothing to do with screen transition animation.
(Swipe Gesture Recognizer
does not change the transition animation naturally.)
You can implement your own original screen transition animation using UIViewControllerAnimatedTransitioning
or UIViewControllerTransitioningDelegate
.
© 2024 OneMinuteCode. All rights reserved.