How to generate CGPoint-Array out of UIBezierPath (to touch-slide object along given path) [duplicate]

♀尐吖头ヾ 提交于 2019-11-30 15:24:09

Use the CGPathApply() function to iterate over all elements in a path. As one of the arguments, you have to specify a pointer to a function that will then be called for each path element. The path element data structure (of type CGPathElement) then contains the point(s) that describe it.

Use NSValue as a wrapper to add the points to an NSMutableArray.

Neither UIBezierPath nor CGPath provide a way to evaluate the points along an arbitrary Bezier path, or a way to find the nearest point on the path. You'll have to write that code yourself.

Fortunately, this is a very well-studied topic. This tutorial has a lot of useful information, to get you started. You're interested in "cubic" or "third-order" Bezier curves.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!