After I hit my head for two days, I was able to create this strange code and it seems to work!
The goal was to push the CAShapeLayer test. CAShapeLayer moves around the screen, so the form is not in a constant place. Hittesting CGPath currentPoint is not simple.
Feel free to add any input ...
- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
CGPoint p = [[touches anyObject] locationInView: self];
CGAffineTransform transf = CGAffineTransformMakeTranslation (-shapeLayer.position.x, -shapeLayer.position.y);
if (CGPathContainsPoint (shapeLayer.path, & transf, p, NO)) {
// the touch is inside the shape
}
}
source share