CGContext透明性问题 [英] CGContext transparency problem

查看:92
本文介绍了CGContext透明性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置了白色背景颜色的UIView。
我已将UIView的CGContext的混合模式设置为 kCGBlendModeCopy。
然后,
1.在该CGContext
中绘制一个UIImage。2.在该上下文中绘制一个alpha为0的路径。

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.

路径覆盖的透明区域显示为黑色,而我的预期输出是它应该是UIView的背景色(即白色)。

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?

在此先感谢,
问候,
Deepa

Thanks in advance, Regards, Deepa

推荐答案

这里没有问题,因此没有解决方案。由于我们以透明的方式绘制UIView的上下文,因此我们可以看到黑色的屏幕。绘图层次结构如下:
1.黑屏
2.在此透明窗口上保留。通过该窗口,我们可以看到屏幕
3。部分透明的视图保留在该窗口中。通过此视图,我们可以看到window(窗口是透明的,因此我们可以看到屏幕)
(视图是部分透明的,因为我正在绘制具有透明路径的视图的一部分)

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)

希望这可以帮助您Naren

Hope this helps you Naren

这篇关于CGContext透明性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆