Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITapGestureRecognizer Point Coordinates

I'm trying to implement a tap gesture recognizer into my app. Ideally I need for the tap gesture to return the x and y coordinates, so I can then create a variable to apply to a core image filter using a parameter which requires the x and y values. e.g, the user taps their nose, the gesture recognizer passes the coordinates(a variable, say, nosePosition.x and nosePosition.y) into a filter such as CIBumpDistorion, which need the x and y values for its kCIInputCenterKey.

I have tried using quite a few methods and moving/deleting code all to no avail. So if anyone has some advice I would be very grateful!

like image 990
Henry Avatar asked Dec 23 '22 23:12

Henry


1 Answers

Would that work ?

func touch(sender: UITapGestureRecognizer) {
    let point = sender.locationInView(self.view)
    let x = point.x
    let y = point.y
}
like image 176
La masse Avatar answered Jan 03 '23 03:01

La masse