我有一个CGPoint值数组。现在我正在做这样的事情:
for(int i=1; i<coveringValuesArray.count; ++i){
CGPoint nextPoint = [coveringValuesArray objectAtIndex:i];
nextPoint = [self offsetPoint:nextPoint on:rect.origin];
CGContextAddLineToPoint(ctx, nextPoint.x, nextPoint.y);
}
需要用曲线绘制此图表。
答案 0 :(得分:0)
试试这个
for(int i=1; i<coveringValuesArray.count; ++i){
CGPoint nextPoint = [coveringValuesArray objectAtIndex:i];
nextPoint = [self offsetPoint:nextPoint on:rect.origin];
CGContextFillRect(context, CGRectMake(nextPoint.x,nextPoint.y,1,1));
}
或者可以使用贝塞尔曲线
UIBezierPath* path = [UIBezierPath bezierPath];
CGPoint firstPoint = coveringValuesArray[0];
[path moveToPoint:firstPoint];
for(int i=1; i<coveringValuesArray.count; ++i){
CGPoint nextPoint = [coveringValuesArray objectAtIndex:i];
nextPoint = [self offsetPoint:nextPoint on:rect.origin];
[path addLineToPoint:nextPoint];
}
[path closePath];