Mat*_*uch 23
取决于你真正想要的.如果你只需要一堆丑陋的酒吧核心情节对你来说可能有点太多了.
实现条形图需要这么多代码.我认为这就像核心数据源所需的代码的一半.即使是一个好的实现也比将核心图集成到项目中花费的时间更少.
核心情节是一个大胖子.像所有那些"我可以做你想做的一切"-frameworks.
- (void)drawRect:(CGRect)rect {
CGFloat height = self.bounds.size.height;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
CGContextSetFillColorWithColor(context, [UIColor grayColor].CGColor);
CGFloat barWidth = 30;
int count = 0;
for (NSNumber *num in values) {
CGFloat x = count * (barWidth + 10);
CGRect barRect = CGRectMake(x, height - ([num floatValue] * height), barWidth, [num floatValue] * height);
CGContextAddRect(context, barRect);
count++;
}
CGContextFillPath(context);
}
Run Code Online (Sandbox Code Playgroud)
Vai*_*kam 13
使用这个好友.:)
编辑
安装Core Plot可能会让您头疼,如果您需要帮助,请告诉我.
如果您需要非常简单的图表,您可以选择ECGraph
| 归档时间: |
|
| 查看次数: |
39815 次 |
| 最近记录: |