他我正在制作简单的饼图,我在绘制它时遇到了问题。我想改变每张饼图的颜色,但是当方法 drawRect: 被调用时,我的饼图是单色的。如何正确制作?
for (int i = 0; i < [values count]; i++) {
CGContextSetRGBFillColor(ctx, 0.2*i, 0.2*i, 0.2*i, 1);
[bezierPath moveToPoint:chartCenter];
startAngle = endAngle;
endAngle = startAngle + [self degreesToRadians:[values[i] floatValue]*step];
NSLog(@"%.2f, %.2f", startAngle, endAngle);
[bezierPath addArcWithCenter:chartCenter radius:radius startAngle:startAngle endAngle:endAngle clockwise:1];
[bezierPath addLineToPoint:chartCenter];
[bezierPath fill];
}