I want to swipe right to show another view and swipe left to get back to first view, Without using storyboard like this example:
Could someone show me how to do that with swift 4
I would assume that if you were to use a swipe gesture, you would do something like:
let swipeGesture = UISwipeGestureRecognizer()
let scrollView = UIScrollView()
swipeGesture.direction = .right
swipeGesture.addTarget(self, action: #selector(scrollToBeginning))
@objc func scrollToBeginning() {
scrollView.setContentOffset(.zero, animated: true)
}
Or using scrollView.scrollRectToVisible(CGRect(x: 0, y: 0, width: 1, height: 1), animated: true)