iphonetransparencycgcontext

CGContext transparency issue


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).

What is the problem here?


Solution

  • 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)