Swift table 带有透明单元格并显示背景图像的视图

Swift table view with a cell that is transparent and shows background image

我试过了:

但是,当我滚动到我的单元格时,我看不到 table 视图后面的橙色视图,它只显示一个灰色单元格。

有人可以提示我还应该做什么吗?

谢谢

在您的 viewDidLoad() 中,立即添加下面的代码以设置 tableView 的背景颜色。

tableView.backgroundColor = UIColor.clearColor()

在您的 cellForRowAtIndexPath 方法中,使用类似于以下代码的内容将给定单元格的背景颜色设置为透明,其中值 2 是您要更改的单元格。

switch indexPath.row {
case 2:
    cell.backgroundColor = UIColor.clearColor()
default:
    print("NOT Clear")
}