I have an image in UIImageView. I have drawn lines on the image sucdcessfully.Now I want to remove that specific line on which user will perform a long press gesture. how can I do that ? my code is :
{
// gets the location in the form of (x,y) coordinates
CGPoint location=[sender locationInView:imageView];
// convetrs the location relative to the image
CGPoint contextLocation = CGPointMake(location.x*imageView.image.size.width/imageView.frame.size.width, location.y*imageView.image.size.height/imageView.frame.size.height);
// converts the location point into NSValue
NSValue *imagePoint=[NSValue valueWithCGPoint:contextLocation];
// Adds the image into NSMutable Array
[imageLocations addObject:imagePoint];
// color of line
UIColor * linearcolor=[UIColor blueColor];
UIGraphicsBeginImageContext(imageView.image.size);
[imageView.image drawAtPoint:CGPointMake(0, 0)];
CGContextRef context=UIGraphicsGetCurrentContext();
// Brush widt
CGContextSetLineWidth(context, 3.0);
// Line Color
CGContextSetStrokeColorWithColor(context, [linearcolor CGColor]);
// Hard coded point for location 2
CGPoint location2=CGPointMake(300, 400);
CGContextMoveToPoint(context, contextLocation.x, contextLocation.y);
CGContextAddLineToPoint(context, location2.x, location2.y);
CGContextStrokePath(context);
newImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageView.image=newImage;
}