我想在背景图像上绘图,什么时候我会擦除该绘图然后只擦除绘图而不是背景图像?我怎样才能实现该任务。通过此代码,我的背景图像也被擦除。
` UITouch *touch = [touches anyObject];
previousPoint2 = previousPoint1;
previousPoint1 = [touch previousLocationInView:self.view];
currentPoint = [touch locationInView:self.view];
CGPoint mid1 = midPoint(previousPoint1, previousPoint2);
CGPoint mid2 = midPoint(currentPoint, previousPoint1);
UIGraphicsBeginImageContext(imageDoodle.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[imageDoodle.image drawInRect:CGRectMake(0, 0, imageDoodle.frame.size.width, imageDoodle.frame.size.height)];
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextSetLineCap(context, kCGLineCapRound);
if(IsErase)
{
CGContextSetBlendMode(context,kCGBlendModeClear);
}
else
{
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), redvalue, greenvalue, bluevalue, 1.0);
}
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 8.0);
CGContextStrokePath(UIGraphicsGetCurrentContext());
imageDoodle.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
`