开发者

Sine wave drawing on iOS

I want to draw a sine wave with changing amplitude in a custom UIView. The value for the amplitude is changed through a timer every 1/30s. The sine wave itself and t开发者_运维百科he animation should look smooth. At the moment I'm trying to do it with CGContextAddCurveToPoint, the curve is pretty smooth, but the point where the curves are connected is rather ugly.

I could also do it by calculating the sine function for every single point and then draw it by moving form one point to another, but it will probably easy to change the amplitude, but a bit pixelated.

I don't really know what's the best way to do it. It has to be nice-looking, fast and easy to do. Or maybe there's something I've forgotten?

I really hope someone can help me.


I think there is a UIBezierPath class that you could use? You could also use OpenGL if your app is graphics-intensive. Also, I think Quartz Composer will let you do sine waves too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜