-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I'm trying to use SVGKit to load an .svg file with named objects in it, and then use hit testing to figure out which object the user has touched. What led me here was this blog post by adamgit and a brief discussion in the comments section.
At any rate, I tried adding a UITouchGestureRecognizer to the sample iPad project and identifying the touched object with the following code
NSLog(@"%@,%@", NSStringFromCGPoint(location), [recognizer.view.layer hitTest:location].name);
It turns out that the accuracy of the hit testing depends on the zoom level. On my simple test file, which contains a blue rectangle and a red rectangle, it works pretty well at the default zoom level, but is still slightly off. However, zooming in/out messes things up a whole lot.
A more complex file, however, does not work accurately even at the default zoom level, but does improve as I zoom in.
I noticed that adamgit has commited a number of changes that remain to be merged with the master branch, including a modification of the hitTest: method in CAShapeLayerWithHitTest. Pasting the changes into the appropriate file in XCode (yeah, I'm not quite there yet with git/github), results in hit testing not working at all at any zoom level. Could be that I missed related code changes in other files.