2012-03-28 58 views
1

我试图设置一个条纹填充用CorePlot创建的图形。我在网上找到一个例子:CorePlot stipes填充

CPColor *firstStripesColor = [CPColor colorWithComponentRed:1.0 green:1.0 blue:1.0 alpha:0.0]; 
       CPColor *secondStripesColor = [CPColor colorWithComponentRed:1.0 green:1.0 blue:1.0 alpha:0.6]; 
       CPFill *areaStripesFill = [CPFill fillWithFirstColor:firstStripesColor secondColor:secondStripesColor stripeWidth:2]; 
       scatterPlot.areaFill = areaStripesFill; 

我觉得这个代码是使用旧版本的CorePlot库(我使用的是1.0)。我只是用CPTColor和CPFill用CPTFill更改CPColor,但没有名为fillWithFirstColor:secondColor:的方法。 我想创建一个像iPhone股票应用程序中的填充。

有什么想法?

非常感谢

克劳斯

回答

2

这里,使背景填充为主题股票代码:

CPTGradient *stocksBackgroundGradient = [[[CPTGradient alloc] init] autorelease]; 

stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.21569 green:0.28627 blue:0.44706 alpha:1.0] atPosition:0.0]; 
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.09412 green:0.17255 blue:0.36078 alpha:1.0] atPosition:0.5]; 
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.05882 green:0.13333 blue:0.33333 alpha:1.0] atPosition:0.5]; 
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.05882 green:0.13333 blue:0.33333 alpha:1.0] atPosition:1.0]; 
stocksBackgroundGradient.angle = 270.0; 
plotAreaFrame.fill = [CPTFill fillWithGradient:stocksBackgroundGradient]; 
+0

是否有可能使图案重复?例如。每隔一个单位有一个梯度,另一个单位是平面? – Setomidor 2012-08-23 06:31:21

+0

在轴上设置'alternatingBandFills'。请参阅示例代码的Plot Gallery示例应用程序。 – 2012-08-23 22:28:53

+1

谢谢!试过,但它没有完全按照我的意图去做。我最终使用了带有透明元素的平铺PNG(取决于您在另一个线程中的建议):) – Setomidor 2012-08-24 07:46:58