I solved the problem with a somewhat ugly hack. Subtract the touch point's x and y by the amount the shape layer is moved. It works, but maybe there is a better solution.
Getting touch in CAShapeLayer after setting the position
-
30-05-2022 - |
Question
I have a series of UIBezierPaths that I combine and add to a CAShapeLayer. I need to detect where on the shape layer the user touches. However, because I changed the position of the shape layer, when I tap on the shape layer, it does not detect the tap because it is comparing the tap coordinates with the coordinates of the bezier paths original location. Does anyone know if I can simply get a tap on the current location of a CAShapeLayer? Instead of relying on its underlying bezier paths for the tap origin.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow