简体   繁体   English

在iPhone上绘制一个简单的图形

[英]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? 有谁知道在我的iPhone应用程序中为我绘制图形的任何现有代码? 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. 我从未处理过iPhone的实际图形。 All my applications are just image based until now. 到目前为止,我的所有应用程序都是基于图像

Thanks! 谢谢!

If you would attempt to draw yourself, you'd use the Path functions to draw in a context in Quartz 如果您尝试绘制自己,则使用Path函数在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 :) 但是可能有一些图书馆可以帮助绘制图表......但是其他人不得不帮助你,而不是我的一杯茶:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM