简体   繁体   English

如何使容器视图背景仅不是全部透明?

[英]how to make container view background transparent only not everything?

I have container view above my view controller 我的视图控制器上方有容器视图

and this container hold xib and have photos in this Xib 这个容器盛放xib,在这个Xib中有照片

the problem is the photos is png and i want the container to be transparent to show me my view colour 问题是照片是png,我希望容器是透明的,以便向我显示我的视图颜色

在此处输入图片说明

在此处输入图片说明

    public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("TNImageCell", forIndexPath: indexPath) as! TNImageSliderCollectionViewCell
    cell.backgroundColor = UIColor.clearColor()
    cell.imageView.image = images[indexPath.row]
    cell.labelSliderName.text = sliderNames[indexPath.row]
    return cell

}

this sample how i fill the container 这个样品我如何装满容器

Try this: tableView.backgroundColor = UIColor.clearColor() and 试试这个: tableView.backgroundColor = UIColor.clearColor()

let cell = collectionView.dequeueReusableCellWithReuseIdentifier("TNImageCell", forIndexPath: indexPath) as! TNImageSliderCollectionViewCell
cell.backgroundColor = UIColor.clearColor()
cell.imageView.image = images[indexPath.row]
cell.imageView.alpha = 0.5
cell.labelSliderName.text = sliderNames[indexPath.row]
return cell

您应该更改容器背景色的不透明度值,而不是alpha.Alpha值也将应用于所有子视图。

声明:本站的技术帖子网页,遵循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? 仅当在iOS 7弹出框内使用视图时,如何使视图背景透明? - How to make the view background transparent only if the view is used inside an iOS 7 popover? 如何使视图变得透明以显示背景内容? - How to make a view become transparent to uncover background content? 如何才能在一个视图控制器中使UINavigationController透明? - How can I make UINavigationController transparent in one view controller only? 如何使UICollection视图的背景透明而不使其中的单元格在Swift中透明 - How can I make the background of UICollection view as transparent without making the cells in it transparent in Swift 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?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM