hea*_*kit 7 objective-c touch ios uibezierpath
我怎么知道触摸点(touchesBegan)是否在隐藏的UIBezierPath上?
Chr*_*yes 10
[bezierPath containsPoint:touchPoint];
Run Code Online (Sandbox Code Playgroud)
只需确保您的触摸点与bezierPaths点在同一坐标系中,并且这些点位于相同的上下文中,即在屏幕空间中.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
if ([self.bezierPath containsPoint:touchPoint])
{
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
另请注意:如果您在某些CoreGraphics绘图中使用UIBezierPath,则需要在touchPoint上翻转y轴,例如...
touchPoint.y = self.view.bounds.size.height - touchPoint.y;
归档时间: |
|
查看次数: |
5365 次 |
最近记录: |