Thanks to manujmv, I was able to figure out Swift 3's implementation of the custom gesture area . In my case, I create 50-dot stripes on each side of the window to transition from one VC to another. But this should be fairly easy to reuse for any other application:
class ViewController: UIViewController { ... var mySensitiveArea: CGRect? ... override func viewDidLoad() { ... let screenWidth = UIScreen.main.bounds.size.width let screenHeight = UIScreen.main.bounds.size.height mySensitiveArea = CGRect(0, 0, 50, screenHeight) let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(self.handleGesture(_:))) swipeGesture.direction = UISwipeGestureRecognizerDirection.right self.view.addGestureRecognizer(swipeGesture) } } //Function for determining when swipe gesture is in/outside of touchable area func handleGesture(_ gestureRecognizer: UIGestureRecognizer) { let p = gestureRecognizer.location(in: self.view) if mySensitiveArea!.contains(p) { print("it inside") showMainViewController() } else { print("it outside") } } //Segue to Main VC func showMainViewController() { self.performSegue(withIdentifier: "toMain", sender: self) }
source share