简体   繁体   English

如何在iPhone OS上绘制具有Alpha透明度的平铺背景图像?

[英]How to draw an tiled background image with alpha transparency on iPhone OS?

When I use UIColor -colorWithPatternImage: to create a view with an tiled background pattern, everything that is supposed to be transparent appears to be black. 当我使用UIColor -colorWithPatternImage:创建带有平铺背景图案的视图时,所有应该是透明的东西似乎都是黑色的。 Of course I can't assign clearColor to the background, since the background is already this pattern image UIColor object. 当然,我不能将clearColor分配给背景,因为背景已经是这个图案图像UIColor对象。

I believe that this internally is using CGContextDrawTiledImage function. 我相信这是内部使用CGContextDrawTiledImage函数。 Or must I go directly with CGContextDrawTiledImage in this case? 或者在这种情况下是否必须直接使用CGContextDrawTiledImage?

You need to have something in the back that is not transparent. 您需要背面有一些不透明的东西。 Otherwise the backmost background (black) will show through your transparent image. 否则,最后的背景(黑色)将通过透明图像显示。

Claus 克劳斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM