iOS Tap Gesture UITapGestureRecognizer
Overview:
- Common class for Tap Gesture
 - You can copy paste the view Extension class
 - Swift 5.0 above
 - Xcode 11 above
 
extension UIView {
    //MARK: addTapGesture
    func addTapGesture(action : @escaping ()->Void ){
        let tap = MyTapGestureRecognizer(target: self , action: #selector(self.handleTap(_:)))
        tap.action = action
        tap.numberOfTapsRequired = 1
        self.addGestureRecognizer(tap)
        self.isUserInteractionEnabled = true
    }
    @objc func handleTap(_ sender: MyTapGestureRecognizer) {
        sender.action!()
        }
}
//MARK: MyTapGestureRecognizer Class
class MyTapGestureRecognizer: UITapGestureRecognizer {
    var action : (()->Void)? = nil
}
Now you can just call
In above code anyView can be anyLabel, anyButton etc.,
Let's grow together 🌱
Cheers 🍻