Set swipe gesture in swift

let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.btnback_Click))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)


func btnback_Click(_ sender: UIButton) {
       navigationController?.popViewController(animated: true)
}