I'm using the following code to create a persistent DrawRect for a finger painting type exercise
When I run on the simulator it is fine, when I run on the iPad it gets delayed turning curves in jagged lines Please can some one help optimize or suggest a better method
Thanks in advance
- (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;
}