如何正确设置 UIView 的透明度?[iOS]

7

我有一个包含许多子视图(UILabel、UITextView等)的UIView

如果将主视图设置为alpha 0.6,所有子视图都会继承这个alpha值。

如何单独设置主视图和子视图的alpha值?

2个回答

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

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

0
myView.layer.shouldRasterize = YES

这将使其使用组透明度,并且一切都应该按照您的预期进行合成。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接