'ポイント'にCGPointを設定した場合、このようなものが機能します。警告:これはクイックカット、貼り付け、編集のジョブです-したがって、おそらくエラーが発生します。また、「ポイント」にはstl::vectorを使用します。他の構造を使用することもできます。
CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef dataPath = CGPathCreateMutable();
bool firstPoint = YES;
for (int i=0; i < points.size(); ++i)
{
CGPoint point = points[i];
if (firstPoint)
{
CGPathMoveToPoint(dataPath, NULL, point.x, point.y);
firstPoint = NO;
}
else
{
CGPathAddLineToPoint(dataPath, NULL, point.x, point.y);
}
}
CGContextSetRGBStrokeColor( context, 1.0, 0.0, 0.0, 1.0);
CGContextSetLineWidth( context, 5);
CGContextBeginPath( context );
CGContextAddPath( context, dataPath );
CGContextDrawPath( context, kCGPathStroke);
CGPathRelease(dataPath);