-1

I want to be able to determine the x,y location where the user clicked a UIImageView in Swift.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Aamir
  • 443
  • 3
  • 16
  • see: https://stackoverflow.com/questions/26829295/getting-the-coordinates-from-the-location-i-touch-the-touchscreen/34735546 – picciano May 03 '18 at 21:30
  • What have you setup so far? Where exactly are you having an issue? Are you using a tap gesture with the image view or something else? Please [edit] your question will all relevant details (do not post comments). – rmaddy May 03 '18 at 22:07
  • 1
    Possible duplicate of [Getting the coordinates from the location I touch the touchscreen](https://stackoverflow.com/questions/26829295/getting-the-coordinates-from-the-location-i-touch-the-touchscreen) – Shivam Tripathi May 04 '18 at 09:45

1 Answers1

2
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    if let touch = touches.first {
        let position = touch.location(in: imageView)
        print(position.x)
        print(position.y)
    }
}
Nader
  • 1,120
  • 1
  • 9
  • 22