tags:

views:

30

answers:

1

Hi there. I'm building an iphone View controller that display two stacked images (on on top of the other). What i need to do is to erase some parts of the image on top (making it transparent while i'm moving my finger on it).

I'll be fine with all the application logic (dragging, saving) but i need to know how i should implement that feature: CALayer, UIView ?

Thanks in advance

A: 

This is thoroughly untested and I have only recently really started grokking CoreGraphics drawing, so I maybe completely wrong. In other words, please let me know if this does indeed work...

So, my thought is you draw your image in your views drawLayer:withContext: using:

CGContextDrawImage(context, CGRectMake(0, 0, image.size.width, image.size.height), [image CGImage]);

Then, in that same drawLayer:withContext: method set a transparent color, and draw your touches after that. Hopefully that will replace your image pixels with transparent pixels on the layer.

ordord00