从UIImageView中删除行

我在UIImageView上绘制了一条直线。 现在,如果用户点击它,我想要删除那条线。 这是我在图像上画一条线的代码。

- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint location=[sender locationInView:imageView]; CGPoint contextLocation = CGPointMake(location.x*imageView.image.size.width/imageView.frame.size.width, location.y*imageView.image.size.height/imageView.frame.size.height); UIColor * linearcolor=[UIColor blueColor]; CGSize imagesize=imageView.image.size; UIGraphicsBeginImageContext(imageView.image.size); [imageView.image drawAtPoint:CGPointMake(0, 0)]; CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGPoint location2=CGPointMake(300, 400); CGContextBeginPath(context); CGContextMoveToPoint(context, contextLocation.x, contextLocation.y); CGContextAddLineToPoint(context, location2.x, location2.y); CGContextAddQuadCurveToPoint(context, contextLocation.x, contextLocation.y, location2.x, location2.y); CGContextSetLineCap(context, kCGLineCapRound); if([removeLine isEqualToString:@"true"]) { CGContextClearRect (context, CGRectMake(location2.x, location2.y, contextLocation.x, contextLocation.y)); CGContextFlush(context); } CGContextSetStrokeColorWithColor(context,[linearcolor CGColor]); CGContextStrokePath(context); UIImage * newImage=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); removeLine=@"true"; imageView.image=newImage; } }