Delete and delete image

I have two overlapping images. If I erase part of the above image, that particular part is erased and the main image appears. But if I take this part off, I have to return the erased part of this image.

I do not need the undo functions, but only the erased part should appear.

Here is the code that I use to remove the above image:

TouchEnglish event:

UIGraphicsBeginImageContext(frontImage.frame.size); [frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); //this line code for erasing select the part of the image CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 10, 10)); //End the code CGContextStrokePath(UIGraphicsGetCurrentContext()); frontImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 

Please help me in solving this problem.

Thanks to everyone in advance.

+1
source share
1 answer

Instead of erasing, why don't you change the alpha for this part of the image. Then, when you want to return, you change the alpha back.

Otherwise, you must restore the entire top image when the bottom is deleted.

+1
source

Source: https://habr.com/ru/post/912523/


All Articles