追踪 CGPath/UIBezierpath
我希望用户能够用手指追踪预定义的 CGPath/UIBezierpath,并在超出线条时收到警告(假设线条粗细为 30px,以使其更容易)。
基于触摸事件方法返回的事件量根据手指的移动而变化的知识,我将如何执行此类检查?
I would like the user to be able to trace a predefined CGPath/UIBezierpath with their finger and get a warning if they go outside of the lines (say the line thickness is e.g. 30px to make it easier).
How would I perform such a check based on the knowledge that the amount of events returned by the touch event methods vary depending on the finger's movement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 CGPathCreateCopyByStrokingPath 创建轮廓描边路径的路径。然后使用 CGPathContainsPoint 来测试触摸点是否在该轮廓内。
Use
CGPathCreateCopyByStrokingPath
to create a path that outlines the stroked path. Then useCGPathContainsPoint
to test whether the touched point is inside that outline.