我在UIImageView中有一個圖像。我已經成功地在圖像上畫出了線條。現在我想要刪除用戶將執行長按手勢的特定線條。我怎樣才能做到這一點 ?我的代碼是:在ios中從UIImage中刪除行
{
// 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;
}
PLZ添加您的代碼.... –
@ Anbu.Karthik請看看我的代碼... –