2009-07-16 9 views
0

Ich möchte ein Rechteck aus Cgpath mit dem folgenden Code abschneiden. Ich bekomme keine Ausgabe. Was ist los mit dir?Problem zu zeichnen und füllen rect nach cgcontextclip

CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGMutablePathRef thePath = CGPathCreateMutable(); 
    CGPathMoveToPoint(thePath,NULL,(self.x1),(self.y1)); 
    CGPathAddLineToPoint(thePath,NULL,(self.x2),(self.y2)); 
    CGPathAddLineToPoint(thePath,NULL,bx2,by2); 
    CGPathAddLineToPoint(thePath,NULL,bx1,by1); 
    CGContextAddPath(context, thePath); 
    CGContextClip(context); 
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); 
    CFRelease(thePath); 

Antwort

0

Haben Sie einen aktuellen Kontext? d. h. haben Sie UIGraphicsBeginImageContext() und UIGraphicsPushContext() verwendet, bevor Sie den angezeigten Code ausführen?

2

Ich bemerkte, dass Sie die Füllfarbe festlegen, aber haben Sie tatsächlich den Pfad gefüllt? z.B.

CGContextFillPath (Kontext);

Verwandte Themen