TapGestureRecognizer this is the code for the initialization of the image view with tap gesture recognizer.
var drawerImageView :UIImageView = {
var drawerImageView = UIImageView()
drawerImageView.image = UIImage(systemName: "list.dash")
let tap = UITapGestureRecognizer(target: HomeViewController.self, action: #selector(tapFunction(sender:)))
tap.numberOfTapsRequired = 1
tap.numberOfTouchesRequired = 1
drawerImageView.addGestureRecognizer(tap)
drawerImageView.isUserInteractionEnabled = true
return drawerImageView
}()
And here below i am setting the constraints for the image view.
drawerImageView.translatesAutoresizingMaskIntoConstraints = false
drawerImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor,constant: 30).isActive = true
drawerImageView.topAnchor.constraint(equalTo: view.topAnchor,constant: 40).isActive = true
drawerImageView.widthAnchor.constraint(equalToConstant: 100).isActive = true
drawerImageView.heightAnchor.constraint(equalToConstant: 100).isActive = true
The problem is i am not able to listen to taps only when i set the width height to more than 200 then only i am receiving the tap events.
this is the objc method for the above tap gesture which will need to call this method but i am not able to receive the control here. @objc func tapFunction(sender:UITapGestureRecognizer) { print("image tap") } This issue is not clear to understand.

Your question is a little hard to notice for me. But I believe you have problem by receiving touch event, if so, the problem is this.
write your touch event outside of your computed variable.
if you want to receive touch when your size is more than 200, just need to write an if in your "tapFunction" and check if the size of your image in more than 200.