Check out example codes for "swift uiview add tap gesture". It will help you in understanding the concepts better.
Code Example 1
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
myView.addGestureRecognizer(tap)
// Then, you should implement the handler, which will be called each time when a tap event occurs:
@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
// handling code
}
Learn ReactJs, React Native from akashmittal.com