开发者

Drawing a simple graph on the iPhone

Does anyone know of any existing code that will draw a graph for me in my iPhone application? I just need a simple line graph without labels or a title or even axis labels for the data.

Or does anyone have ideas about where to start so that I can learn how to draw such a thing? I've never dealt with actual graphics for the iPhone. Al开发者_开发百科l my applications are just image based until now.

Thanks!


Try out the Core Plot framework http://code.google.com/p/core-plot/


If you would attempt to draw yourself, you'd use the Path functions to draw in a context in Quartz

CGContextBeginPath(context);
CGContextMoveToPoint(context, startX, startY);
CGContextAddLineToPoint(context, nextX, nextY);
// [...] and so on, for all line segments
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] cgColor]);
CGContextStrokePath(context);

There is a lot of sample code to deal with context and drawing in quartz.

But there are probably some libraries to facilitate drawing graphs... someone else would have to help you with those though, not my cup of tea :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜