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.
有谁知道在我的iPhone应用程序中为我绘制图形的任何现有代码?我只需要一个没有标签的简单折线图或数据的标题甚至轴标签。
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. All my applications are just image based until now.
或者有没有人有关于从哪里开始的想法,以便我可以学习如何绘制这样的东西?我从未处理过iPhone的实际图形。我的所有应用程序都是基于图像的,直到现在
Thanks!
2 个解决方案
#1
8
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 :)
但是可能有一些图书馆可以帮助绘制图表...其他人不得不帮助你,但不是我的一杯茶:)
#2
10
Try out the Core Plot framework http://code.google.com/p/core-plot/
试用Core Plot框架http://code.google.com/p/core-plot/
#1
8
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 :)
但是可能有一些图书馆可以帮助绘制图表...其他人不得不帮助你,但不是我的一杯茶:)
#2
10
Try out the Core Plot framework http://code.google.com/p/core-plot/
试用Core Plot框架http://code.google.com/p/core-plot/