我想使用UIBezierPath填充圖中的顏色。到目前爲止我已經使用以下代碼:在UIBezierPath中填充顏色
NSMutableArray *graphData=[[NSMutableArray alloc] initWithObjects:[NSArray arrayWithObjects:@"2013-06-26",@"46", nil],[NSArray arrayWithObjects:@"2013-06-27",@"37", nil],[NSArray arrayWithObjects:@"2013-06-28",@"96", nil],[NSArray arrayWithObjects:@"2013-06-29",@"29", nil],[NSArray arrayWithObjects:@"2013-06-30",@"29", nil],[NSArray arrayWithObjects:@"2013-07-01",@"24", nil], nil];
UIBezierPath *aPath = [UIBezierPath bezierPath];
[[UIColor blackColor] setStroke];
[[UIColor redColor] setFill];
[aPath moveToPoint:CGPointMake(10, kGraphBottom-[[[graphData objectAtIndex:0] objectAtIndex:1]floatValue])];
for (int i = 1; i < graphData.count; i++)
{
[aPath addLineToPoint:CGPointMake(10+50* (i), kGraphBottom-[[[graphData objectAtIndex:i] objectAtIndex:1]floatValue])];
}
[aPath moveToPoint:CGPointMake(10+50*graphData.count , kGraphBottom)];
[aPath moveToPoint:CGPointMake(10 , kGraphBottom)];
[aPath moveToPoint:CGPointMake(10 , kGraphBottom-[[[graphData objectAtIndex:0] objectAtIndex:1]floatValue])];
[aPath closePath];
[aPath fill];
[aPath stroke];
就像圖像下面所示的是我得到的輸出:
我怎樣才能填充圖形和在x,y軸之間的顏色?
你的問題是什麼? –
編輯該問題。請閱讀 –
+1好問題 – Warewolf