简体   繁体   English

如何使视图变得透明以显示背景内容?

[英]How to make a view become transparent to uncover background content?

I have set an image in background using this code: 我已经使用以下代码在后台设置了图像:

 self.tableView.backgroundColor = UIColor(patternImage: UIImage(named: "image1")!)

However, I have some contentView on top, and I am trying to have those transparent to unveil the background. 但是,我在顶部有一些contentView,并且我试图使这些透明显示背景。

How can this be done ? 如何才能做到这一点 ? Thanks 谢谢

Use alpha 使用alpha

self.contentView.alpha = 0.1

If alpha = 1.0 then the view is opaque, you can also set it to 0. 如果alpha = 1.0则视图是不透明的,您也可以将其设置为0。

for that view do the following : 对于该视图,请执行以下操作:

thatView.backgroundColor = UIColor.clearColor() thatView.backgroundColor = UIColor.clearColor()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使他的背景透明 - How to make view his background transparent 如何在 SwiftUI 中制作具有透明背景的模态视图? - how to make the modal view with a transparent background in SwiftUI? 如何使容器视图背景仅不是全部透明? - how to make container view background transparent only not everything? UIPageControl - 如何使背景透明? - UIPageControl - How to make the background transparent? 如何使ClipPath的背景透明? - How to make background of ClipPath transparent? 如何使PageviewController的背景透明 - How to make for Pageviewcontroller background transparent 如何使UINavigationBar背景透明? - How to make UINavigationBar background transparent? 如何使UICollection视图的背景透明而不使其中的单元格在Swift中透明 - How can I make the background of UICollection view as transparent without making the cells in it transparent in Swift 使 UIView 的一部分变得透明 - make a portion of a UIView become transparent 仅当在iOS 7弹出框内使用视图时,如何使视图背景透明? - How to make the view background transparent only if the view is used inside an iOS 7 popover?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM