Adding a UITapGestureRecognizer to a UIView is very straighforward. All you do is setup the gesture and then assign it to the view. Could not be much easier could it.
1 2 |
let tapRecogniser = UITapGestureRecognizer(target: self, action: #selector(ViewController.viewPressed(_:))) myView.addGestureRecognizer(tapRecogniser) |
There are a couple of points just to hightlight. Firstly if you are using a UIImageView then you will need to add in the […]