问题
I have an UIView which has white background color set. I have set the blending mode of the CGContext of the UIView as 'kCGBlendModeCopy'. Then, 1. Draw an UIImage in that CGContext 2. Draw a path with alpha as 0 in that context.
The transparent area covered by the path appears in black whereas my expected output was that it should be UIView's background color (i.e. white).
Does anyone knows what is the problem here?
Thanks in advance, Regards, Deepa
回答1:
There is no problem here and hence no solution. Since we are drawing on the UIView's context with transparency, we can see the screen that is in black color. The drawing hierarchy is like this: 1. Black screen 2. On this transparent window is kept. Through this window we can see the screen 3. A view that is partially transparent is kept on this window. Through this view we can see window(Window is transparent and hence we can see screen) (View is partially transparent because I am drawing part of the View with transparent path)
Hope this helps you Naren
回答2:
Maybe this article can help you..
http://losingfight.com/blog/2007/08/18/how-to-implement-a-basic-bitmap-brush/
回答3:
I understood the problem after putting some more effort:
CGContext is not a separate drawing layer of UIView. UIView is a cocoa wrapper for CGContext drawing. Since I am drawing the path with transparency, the screen behind the UIView is visible.
来源:https://stackoverflow.com/questions/4525127/cgcontext-transparency-problem