开发者

Background of UILabel visible after a composite

I am doing something a bit unusual. I'm trying to tint all the components in my application red (you may have seen some other postings from me about this, but this is something more specific). To do so, I'm intercepting all calls to CALayer's drawInContext: and after calling the original method, I composite red onto the layer using kCGBlendModeDarken (or kCGBlendModeMultipy). This works surprisingly well for most UI components. However, when I do this with UILabels, the previously transparent background becomes white (well, actually a red-tinted white). You can see what this looks like in this image of my toolbar

http://www.thinkastronomy.com/RedLabels.png

Note that the UIImages also aren't tinted, but that is the topic of another question.

So can an开发者_JAVA技巧yone explain why the UILabel background would be made visible by this compositing? It seems to happen pretty much independent of the compositing mode. How can I prevent this?


Is opaque set to NO on the labels and all transparent views behind them? The opaque value is a quirk in UIViews that can cause problems with transparent backgrounds. From the docs: "YES if it is opaque; otherwise, NO. If opaque, the drawing operation assumes that the view fills its bounds and can draw more efficiently. The results are unpredictable if opaque and the view doesn’t fill its bounds. Set this property to NO if the view is fully or partially transparent. The default value is YES."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜