Swift4:如何更改UITableView单元格颜色

Swift4:如何更改UITableView单元格颜色,swift,uitableview,tableview,background-color,Swift,Uitableview,Tableview,Background Color,我有一个UITable视图,您可以通过按按钮添加项目。我希望它的单元格是清晰的,我已经使它的背景是半透明的,但一旦你点击按钮,允许你保存其中的项目,你保存的第一个有一个白色的背景。然后,如果您在其他时间按下该按钮,则除上次创建的单元格外,所有单元格都将变为半透明,但其中一个单元格仍为白色。这是我的代码,我怎么能把它说清楚呢 extension ViewController : UITableViewDataSource { func tableView(_ tableView: UITa

我有一个UITable视图,您可以通过按按钮添加项目。我希望它的单元格是清晰的,我已经使它的背景是半透明的,但一旦你点击按钮,允许你保存其中的项目,你保存的第一个有一个白色的背景。然后,如果您在其他时间按下该按钮,则除上次创建的单元格外,所有单元格都将变为半透明,但其中一个单元格仍为白色。这是我的代码,我怎么能把它说清楚呢

extension ViewController : UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return number.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let textCell = tableView.dequeueReusableCell(withIdentifier: "WordCell", for: indexPath)
        textCell.textLabel?.text = "\(indexPath.row + 1)         \(number[indexPath.row])"
        let semitransparentBlack = UIColor(rgb: 0x000000).withAlphaComponent(0.3)
        textCell.layer.backgroundColor = semitransparentBlack.cgColor
        textCell.textLabel?.layer.backgroundColor = semitransparentBlack.cgColor
        textCell.textLabel?.textColor = UIColor.white
        return textCell

    }


}

你可以使用
textCell.backgroundColor=semi-transparentblack

设置颜色你试过
textCell.backgroundColor=semi-transparentblack
吗?太好了,谢谢,我不知道没有图层我能做到,我是说,当我试过其他时候,我收到了错误消息。。。谢谢,看起来很棒!如果您可以尝试
textCell.contentView.backgroundColor=semi-transparentblack