2016-11-13 38 views
0

這非常簡單。我已經在tableView:willDisplayCell:forRowAtIndexPath:tableView:CellForRow:atIndexPath:中嘗試了幾次。無法使UITableViewCell具有清晰的顏色

這裏是我的代碼:

cell.alpha = 0.0 
cell.backgroundView?.alpha = 0.0 
cell.contentView.alpha = 0.0 
cell.backgroundView?.backgroundColor = UIColor.clear 
cell.backgroundColor = UIColor.clear 
cell.contentView.backgroundColor = UIColor.clear 

我敢肯定這應該是矯枉過正,但我​​有一個很艱難的時期使這項工作。單元格在if語句內被修改,因爲這隻適用於某些單元格。是的,我檢查過了,if語句按預期工作。有任何想法嗎?

我使用的Xcode 8.2版本的測試版

回答

1

您應該設置:

cell.backgroundColor = .clear 

,你也應該爲整個的tableView提供清晰的色彩:

tableView.backgroundColor = .clear 

我在樣品測試過項目。我用UITableView創建了UIViewController。設置.red顏色爲viewUIViewController。創建UITableView,爲celltableView應用.clear顏色。你應該看到紅色的背景 - 所以單元格和tableView是透明的。

下面是示例性屏幕(該標籤被添加到的UIViewController.view確保tableView是透明的):

enter image description here