class ViewController: UIViewController {
let customView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handleTap(_:)))
customView.addGestureRecognizer(panGestureRecognizer)
}
func handleTap(panGesture: UIPanGestureRecognizer) {
}
}
Don't forget to add your custom UIView to the VC.