如何在 iPhone 中创建饼图?
我想按百分比显示我的类别的饼图。
如何创建类别百分比饼图?
I want to show pie chart of my category by percentage.
How can I create pie chart of category percentage ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须实现一个重写
drawRect:
方法的类并自己绘制饼图。您可以使用 UIBezierPath 类,具体查看 addArcWithCenter:radius:startAngle:endAngle:顺时针:方法绘制圆的一部分。另请参阅本文和这篇文章。
You have to implement a class which overrides the
drawRect:
method and draw the pie yourself. You'd use UIBezierPath class, specifically look into the addArcWithCenter:radius:startAngle:endAngle:clockwise: method to draw a part of a circle.See also this article and this article.
有API可以让你做这件事。
There is API by that you can do this thing.
这可能有助于警告“如果它看起来像其他人的代码,那是因为我研究了如何通过网站执行此操作”,以及附加警告“我在启动 iPhone 后不久就这样做了”。欢迎那些想告诉我哪些部分效率低下或错误的人,我仍在学习。
This might be helpful with the warning that if it looks like someone else's code, it's because I worked out how to do it with web sites, and the additional warning that I did this not long after starting iPhone. People who want to tell me which bits are inefficient or wrong are welcome, I'm still learning.
除了其他答案中建议的库之外,我还使用了两个非常好的开源饼图类。它们看起来非常漂亮,而且非常简单,请在 GitHub 上查看它们:
XYPieChart
NBPieChart
Besides the proposed library in the other answers, there are two really good open source pie chart classes that I used. They look very nice, are extremely simple, have a look at them at GitHub:
XYPieChart
NBPieChart