xcode 7 swift如何使容器视图透明

时间:2022-04-13 16:46:57

I have 5 tabs in my application. I need to add a floating button for quick action on all my tabs.

我的应用程序中有5个选项卡。我需要添加一个浮动按钮,以便在我的所有标签上快速操作。

I've managed to add the floating button at the bottom, just above the tab bar using a container view. So the container is positioned at bottom right and has a view controller which holds the button.

我已经设法使用容器视图在标签栏的正上方添加浮动按钮。所以容器位于右下方,并有一个视图控制器,用于固定按钮。

The problem is, if I add table views to my pages, since the container view is in front, a part of table views gets hidden. How do I make the container view transparent, so the user can see and scroll properly the table view..

问题是,如果我将表视图添加到我的页面,由于容器视图在前面,表视图的一部分会被隐藏。如何使容器视图透明,以便用户可以正确查看和滚动表视图。

2 个解决方案

#1


2  

Try to use yourContainerView.backgroundColor = UIColor.clearColor()

尝试使用yourContainerView.backgroundColor = UIColor.clearColor()

Swift 3: yourContainerView.backgroundColor = UIColor.clear

Swift 3:yourContainerView.backgroundColor = UIColor.clear

#2


2  

You just need to decrease the value of alpha from the attribute inspector . 1 signifies max value (default value too) and 0 means complete transparent.

您只需要从属性检查器中减少alpha的值。 1表示最大值(默认值也是),0表示完全透明。

#1


2  

Try to use yourContainerView.backgroundColor = UIColor.clearColor()

尝试使用yourContainerView.backgroundColor = UIColor.clearColor()

Swift 3: yourContainerView.backgroundColor = UIColor.clear

Swift 3:yourContainerView.backgroundColor = UIColor.clear

#2


2  

You just need to decrease the value of alpha from the attribute inspector . 1 signifies max value (default value too) and 0 means complete transparent.

您只需要从属性检查器中减少alpha的值。 1表示最大值(默认值也是),0表示完全透明。