我正在用图像填充piePlot的叠加层,而不是用渐变颜色填充。
这是代码:
piePlot.pieRadius = radius;
piePlot.identifier = @"1";
piePlot.startAngle = 0.0;
piePlot.sliceDirection = CPTPieDirectionCounterClockwise;
piePlot.borderLineStyle = [CPTLineStyle lineStyle];
piePlot.labelOffset = 5.0;
piePlot.overlayFill = [CPTFill fillWithImage:[CPTImage imageWithCGImage:[UIImage imageNamed:@"pointerPie.png"].CGImage]];
piePlot.centerAnchor = CGPointMake(0.5, 0.5);
这里的问题只是我可以看到的叠加图像的一部分,而不是完整的图像。如果我用任何其他颜色填充它,它工作正常。
我在这里做错了什么。谁能告诉我我在这里做错了什么?
您需要
设置图像填充的scale
,以便正确绘制图像填充。您可以在创建CPTImage
时执行此操作:
UIImage *image = [UIImage imageNamed:@"pointerPie.png"];
piePlot.overlayFill = [CPTFill fillWithImage:[CPTImage imageWithCGImage:image.CGImage
scale:image.scale]];