我正在使用以下代码为手指绘画类型练习创建一个持久的 DrawRect
当我在模拟器上运行时很好,当我在 iPad 上运行时,它会延迟转弯曲线呈锯齿状 请有人帮助优化或提出更好的方法
提前致谢
- (void)drawRect:(CGRect)rect
{
UIGraphicsPushContext(drawingContext);
CGImageRef cgImage = CGBitmapContextCreateImage(drawingContext);
image = [[UIImage alloc] initWithCGImage:cgImage];
if (draw) {
CGContextSetLineWidth(drawingContext, (2.0 * size) );
CGContextSetStrokeColorWithColor(drawingContext, color);
CGContextSetLineCap(drawingContext,kCGLineCapRound);
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);
} else {
// CGContextSetFillColorWithColor(drawingContext, [[UIColor redColor] CGColor]);
// CGContextFillRect(drawingContext, CGRectMake( currPt.x - (31.0 / self.transform.a) - 16.0 , currPt.y - (31.0 / self.transform.a) - 16.0 , 40.0 , 40.0) );
CGContextClearRect(drawingContext, CGRectMake( currPt.x - (31.0 / self.transform.a) - 16.0 , currPt.y - (31.0 / self.transform.a) - 16.0 , 40.0 , 40.0) );
}
UIGraphicsPopContext();
CGImageRelease(cgImage);
NSLog(@" %@ " , rect);
[image drawInRect: rect];
lastPt = currPt;
}