I draw the lines and any shapes as i want but while erasing it not working,
For drawing i used the following code
in this code i drawn by using quartz core
previousPoint1 = [touch previousLocationInView:m_img];
previousPoint2 = [touch previousLocationInView:m_img];
currentPoint = [touch locationInView:m_img];
//
previousPoint2 = previousPoint1;
previousPoint1 = [touch previousLocationInView:m_img];
currentPoint = [touch locationInView:m_img];
// calculate mid point
CGPoint mid1 = [self midPoint:previousPoint1 :previousPoint2];
CGPoint mid2 =[self midPoint:currentPoint :previousPoint1];
UIGraphicsBeginImageContext(m_img.frame.size);
[m_img.image drawInRect:CGRectMake(0, 0, m_img.frame.size.width, m_img.frame.size.height)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context, mid1.x, mid1.y);
// Use QuadCurve is the key
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGBitmapContextGetColorSpace(context);
//CGContextSetStrokeColor(<#CGContextRef context#>, <#const CGFloat *components#>)
CGContextSetStrokeColorWithColor(context, color.CGColor);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context,m_width);
CGContextStrokePath(context);
m_img.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
and for erasing the drawing i used the following code
m_widthString=[userdefault valueForKey:@"EraserWidth"];
m_width=[m_widthString floatValue];
previousPoint1 = [touch previousLocationInView:m_img];
previousPoint2 = [touch previousLocationInView:m_img];
currentPoint = [touch locationInView:m_img];
previousPoint2 = previousPoint1;
previousPoint1 = [touch previousLocationInView:m_img];
currentPoint = [touch locationInView:m_img];
// calculate mid point
CGPoint mid1 = [self midPoint:previousPoint1 :previousPoint2];
CGPoint mid2 =[self midPoint:currentPoint :previousPoint1];
UIGraphicsBeginImageContext(m_img.frame.size);
[m_img.image drawInRect:CGRectMake(0, 0, m_img.frame.size.width, m_img.frame.size.height)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context,m_width);
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextDrawPath(context, kCGPathFillStroke);
m_img.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
while erasing i changed blend mode clear even if it is not working
but is not working please help me
for erasing u have to take trasferent image view
and use CGContextSetBlendMode(context, kCGBlendModeClear);
its working right now for me…