How could I know if a touch point (touchesBegan) is on a hidden UIBezierPath?
[bezierPath containsPoint:touchPoint];
Just make sure that your touch point is in the same coordinate system as the bezierPaths points and that the points are within the same context i.e. both in screen space.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
if ([self.bezierPath containsPoint:touchPoint])
{
// do stuff
}
}
Also note: If you are using your UIBezierPath in some CoreGraphics drawing you will want to flip the y-axis on the touchPoint for example...
touchPoint.y = self.view.bounds.size.height - touchPoint.y;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With