ios - 如何使容器 View 背景透明而不是一切?

标签 ios xcode swift swift2

我的 View Controller 上方有容器 View

这个容器里装着xib,在这个xib里有照片

问题是照片是 png,我希望容器是透明的以显示我的 View 颜色

enter image description here

enter image description here

    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

}

这个示例我是如何填充容器的

最佳答案

试试这个: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

关于ios - 如何使容器 View 背景透明而不是一切?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36678603/

相关文章:

ios - 如何在已经存在的模型中添加实体

javascript - Phonegap Build in iphone exec 错误

ios - 使用企业配置文件签署 swift 应用程序

ios - Swift - 如何检查 NSDate 是否是昨天与当前时间相比?

ios - 快速更改所选标签栏图标的颜色

ios - 使用 exit-segue 时的 viewWillAppear 和 viewDidAppear

ios - 从 html 链接重定向到 IOS 应用程序

iphone - 嵌套 UINavigationController 流已损坏

ios - 从 View Controller 对负 y 原点进行动画处理会破坏约束

cocoa - XCode Cocoa 控制台应用程序链接错误