Question

I really wonder how can we erase the imageview layer? I have an application in which I need to capture the two images one over the other, with only change in background. After that I need to erase that image layer which was firstly captured. I google a lot but cannot find any idea to erase the background image by just moving the finger over it. Can any body give me some idea about it Thanks.

Était-ce utile?

La solution

Well, you can always do imageView.layer.contents=nil;, but I am not sure that this is exactly what you need.

This is the modified version from the comments below:

Use UIGraphicsBeginImageContext() to create image context. You can draw UIImageView by calling -drawInRect: method, and then you should create path, that will contain areas you want to "erase", and set CGContextSetBlendMode(context, kCGBlendModeClear). Stroke the path after that, and capture the resulting image by calling UIGraphicsGetImageFromCurrentImageContext(). Then just call UIGraphicsEndImageContext() to clean up.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top