开发者

Drawing a 'turning wheel' using Core Graphics?

Can someone provide an example of drawing an iPhone-like turning wheel using Core Graphics. I know it can be done by drawing a sequence of lines but that requires a math formula to work out line points. Can someone help me with that?

Here is how it should look like:

Drawing a 'turning wheel' using Core Graphics?

It looks like it is made up of several lines with rounded edges and a circle drawn in the middle. D开发者_运维问答rawing the lines requires sophisticated maths.


That requires no sophisticated maths, only simple geometry. The points on a circle are described with the equations

 x = r * cos a
 y = r * sin a

for the radius r and any angle a from 0 to 2π.

You can figure out the angles by dividing the whole circle (2π) by the number of lines you need. With that info you can calculate the start- and end points of the lines and draw them.

But it's probably better to use the system-provided progress indicator or store the animation frames as images and draw those instead of relying on code to do all the drawing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜