如何正确设置UIView的alpha? [iOS]

问题描述:

我有UIView有很多子视图(UILabel,UITextView等)。如何正确设置UIView的alpha? [iOS]

如果设置alpha 0.6到主视图,所有的子视图都需要这个alpha。

如何分别设置主视图的alpha?

[view setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.5]]; 

//try this.. dont try to set alpha of UIView and also your subviews will not affect 
+0

我觉得有用))谢谢!!! – Romowski

myView.layer.shouldRasterize = YES 

这将使它使用group opacity,一切都应该像你期望的那样复合。

+0

这不行( – Romowski