iOS如何使透视视图的子视图不透明? [英] iOS how to make subview of a transparent view opaque?
本文介绍了iOS如何使透视视图的子视图不透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个视图作为另一个视图的子视图,然后我将父视图的alpha值设置为0.5,但这也使得子视图即使其alpha值设置为1也是透明的。所以我该如何制作子视图的父视图的alpha值小于1时非透明(不透明)吗?
I have a view as the subview of another view, then I set the alpha value of the father view something like 0.5, but this also makes the subview transparent even when its alpha value is set to 1. So how can I make the subview non-transparent(opaque) when its father view has an alpha value less than 1?
推荐答案
离你最近的那个得到的是 colorWithAlphaComponent:
。使用类似下面的内容,您可以设置父视图背景的alpha分量,它不会影响子视图。
The closest you're going to get is colorWithAlphaComponent:
. Using something like the following, you can set the alpha component of the parent view's background, and it won't affect subviews.
[yourSuperview setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.5]];
这篇关于iOS如何使透视视图的子视图不透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文