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 축 사이의 색을 채울 수 있습니까?
그리고 귀하의 질문은 무엇입니까? –
question.please 읽기 편집 –
+1 좋은 질문 – Warewolf