2013-03-22 59 views
0

我画与CorePlot,这我变成了查看,打印和电子邮件发送PDF的饼图。所有这一切都很好,除了当我添加一个borderLineStyle时,我还会在饼图的边缘产生人为因素。CorePlot饼图borderLineStyle文物

你真的不注意到他们的iPhone的屏幕上,或当打印,但通过电子邮件和在大屏幕上(在Acrobat Reader)看时,他们立即明显。此屏幕截图缩放至400%,但它们在100%时也清晰可见。您可以在饼图的内部和外部看到裁剪工件。

CPTPieChart with artifacts round the edges

如果我离开关borderLineStyle然后饼图是非常干净的。只有在设置了线条样式时才会显示人工制品。我这样做:

CPTMutableLineStyle *segmentLineStyle = [CPTMutableLineStyle lineStyle]; 
segmentLineStyle.lineColor = colour; 
segmentLineStyle.lineWidth = size; 
_pieChart.borderLineStyle = segmentLineStyle; 

对我来说,它们看起来像裁剪或抖动的文物,所以我尝试设置背景颜色和图形填充为白色或透明的,但是这并没有区别。

我使用CorePlot 1.1。有没有人有任何想法,为什么发生这种情况?任何帮助将非常感激。

谢谢。

+1

您是否使用了覆盖层或影子?核心图形呈现为不支持透明度的旧PDF格式。 – 2013-03-23 10:02:34

+0

谢谢埃里克,我使用覆盖,但我没有尝试过,这没有什么区别:( – AW101 2013-03-25 20:27:38

回答

0

要回答我的问题。感谢Eric提示Core Graphics呈现不支持幻灯片的旧PDF格式,我想我会改变我推销饼图的方式。

以前我只是渲染饼图到PDF背景下,这样的:

CGContextRef pdfContext = UIGraphicsGetCurrentContext(); 
[pieChartView.layer renderInContext:pdfContext]; 

现在,我第一次渲染饼图一个UIImage,然后渲染图像的PDP上下文。就像这样:

// Pre-render the pie chart into a temporary UIImage 
UIGraphicsBeginImageContextWithOptions (pieChartView.frame.size, YES, 0.0f); 
CGContextRef tmpContext = UIGraphicsGetCurrentContext(); 
[pieChartView.layer renderInContext:tmpContext]; 
UIImage *pieChartTmpImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

// Draw the pre-rendered pie chart in to the PDF context. 
[pieChartTmpImage drawInRect:CGRectMake(0, 0, pieChartTmpImage.size.width, pieChartTmpImage.size.height)]; 

现在,这使得该饼图干净:)

这是值得指出的是,当这个代码运行并临时图像内容被嵌套在PDP上下文已经建立,但是这是精细。

+0

你可以使用'-imageOfLayer'方法从Core Plot图层获得'UIImage'。 – 2013-03-25 22:55:56

+0

是的,这将工作我的问题是我的'pieChartView'包含需要渲染,一些核心的情节,有些不是。'renderInContext'只是它所有一气呵成:)你的帮助感谢几个要素! – AW101 2013-03-26 22:16:57