Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
How could I know if a touch point (touchesBegan) is on a hidden UIBezierPath?
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
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;