我终于设法得到了一直没有清除的 DrawRect (我也有 setClearsContextBeforeDrawing:YES )
- (void)drawRect:(CGRect)rect
{
UIGraphicsPushContext(drawingContext);
CGImageRef cgImage = CGBitmapContextCreateImage(drawingContext);
UIImage *uiImage = [[UIImage alloc] initWithCGImage:cgImage];
CGContextSetLineWidth(drawingContext, 4.0);
if (draw)
CGContextSetStrokeColorWithColor(drawingContext, [UIColor whiteColor] CGColor]);
else
CGContextSetStrokeColorWithColor(drawingContext, [[UIColor clearColor] CGColor]);
CGContextMoveToPoint(drawingContext, lastPt.x - (31.0 / self.transform.a), lastPt.y - (31.0 / self.transform.a) );
CGContextAddLineToPoint(drawingContext, currPt.x - (31.0 / self.transform.a), currPt.y - (31.0 / self.transform.a) );
CGContextStrokePath(drawingContext);
UIGraphicsPopContext();
CGImageRelease(cgImage);
[uiImage drawInRect: rect];
lastPt = currPt;
}
这会在绘制时留下一条线
我的问题是当绘制为 NO [UIColor clearColor] 未擦除时我应该用什么来擦除?提前致谢