2012-03-28 57 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