Let say I have two UIViews:
View1:
– bounds: 0, 0, 20, 20
– background color: some complex background with a gradient or something
View2:
– frame: 0, 0, 20, 20
– background color: blue
– is a subview of View1 and completely covers it
Next I want to draw some text on View2(using a CATextLayer or any other way) and I want the text to be transparent so that it shows View1’s background.
I’ve thought hard about this one but with no results. Anyone knows how to do this?
Thank you,
Antoni
Normally, setting the color to clear and drawing the text would result in no visible effect. But if you first use
CGContextSetBlendModewithkCGBlendModeCopy, it should completely replace the (colored) pixels in View2’s background with the transparent color you set when drawing the text.