【发布时间】:2013-06-19 03:40:54
【问题描述】:
我正在绘制一个条形图,它工作正常,只是它没有动画。例如:填充颜色 0-50%。 我正在使用简单的 DrawRect 方法来绘制这里是我的代码:
- (void)drawRect:(CGRect)rect
{
CGFloat height = self.bounds.size.height;
CGContextRef context = UIGraphicsGetCurrentContext();
// CGContextClearRect(context, rect);
CGContextSetFillColorWithColor(context, [self colorWithR:149 G:21 B:29 A:1].CGColor);
CGFloat barWidth = 52;
int count = 0;
NSNumber *num = [NSNumber numberWithFloat:graphValue];
CGFloat x = count * (barWidth + 10);
CGRect barRect = CGRectMake(x, height - ([num floatValue] * height), barWidth, [num floatValue] * height);
CGContextAddRect(context, barRect);
count++;
CGContextFillPath(context);
}
请帮我知道添加动画的简单方法。
【问题讨论】:
-
那不是你的代码。您将它从 my answer 逐字复制到 your previous question 没有一点点赞。
-
对不起,我粘贴了错误的代码。现在更新我的代码。
标签: ios core-graphics