title: Erase and un erase a image in UIImageVIew with touch using coregraphics
body: <p>My question is same as mentioned at <a href="https://stackoverflow.com/questions/1382689/erase-and-unerase-image">here</a>. I'm also using two images in my app and all I need is to erase a top image by touch. Then un-erase (if required) the erased part by touch. I'm using following code to erase the the top image. There is also a problem in this approach. Which is that the images are big and I'm using Aspect Fit content mode to properly display them. <strong>When I touch on the screen, it erase in the corner not the touched place.</strong> I think the touch point calculation is required some fix. Any help will be appreciated.</p>
  
  <p><strong>Second problem is that how to un-erase the erased part by touch?</strong></p>
  
  <pre><code>UIGraphicsBeginImageContext(self.imgTop.image.size);
  [self.imgTop.image drawInRect:CGRectMake(0, 0, self.imgTop.image.size.width, self.imgTop.image.size.height)];
  self.frame.size.width, self.frame.size.height)];
  CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
  GContextSetLineWidth(UIGraphicsGetCurrentContext(), pinSize); 
  CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0, 0, 0, 1.0);
  CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
  
  CGContextBeginPath(UIGraphicsGetCurrentContext());
  CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
  CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
  CGContextStrokePath(UIGraphicsGetCurrentContext());
  self.imgTop.contentMode = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  </code></pre>