1

次の問題があります:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetLineCap(context,kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetRGBFillColor(context, 1, 0, 0, 1);

for (drawnCurve *line in completeLines) {
CGContextBeginPath(context);    
    for(int i=0;i<[line.points count]-1;i++) 
    { 
    drawnPoint*point=[line.points objectAtIndex:i];
    drawnPoint*point2=[line.points objectAtIndex:i+1];

   // CGContextSetLineWidth(context, point.r);
    [point.color set];
    CGContextMoveToPoint(context, point.x,point.y);
        CGContextAddLineToPoint(context, point2.x, point2.y);  
    // CGContextAddCurveToPoint(context, (point.x+point2.x)/2, point2.y, (point.x+point2.x)/2, point2.y, point2.x, point2.y);

        //CGContextEOFillPath(context);
    }
    CGContextClosePath(context);
    CGContextFillPath(context);
}

しかし、それはただ消えており、塗りつぶされた曲線が表示されていません..問題は何ですか?

4

1 に答える 1

1

への呼び出しCGContextMoveToPointは、新しいサブパスを開始します。forネストされたループの前に一度呼び出してから、CGContextAddLineToPoint回線接続を維持するためにのみ使用する必要があります。

drawnPoint*pointZero=[line.points objectAtIndex:0];
CGContextMoveToPoint(context, pointZero.x,pointZero.y);
for(int i=1;i<[line.points count];i++) 
{ 
    drawnPoint*point=[line.points objectAtIndex:i];
    CGContextAddLineToPoint(context, point.x, point.y);  
}
CGContextClosePath(context);
CGContextFillPath(context);
于 2012-08-06T19:02:31.367 に答える