gpt4 book ai didi

swift 4 : How to change UITableView cell color

转载 作者:行者123 更新时间:2023-11-28 05:45:00 25 4
gpt4 key购买 nike

我有一个 UITable View ,您可以在其中通过按一个按钮来添加项目。我希望它的单元格清晰,我已经将它的背景设为半透明,但是一旦您单击允许您在其中保存项目的按钮,您保存的第一个就会有白色背景。然后,如果您再次按下该按钮,除最后创建的单元格外,所有单元格都变为半透明,但有一个继续为白色。这是我的代码,我怎样才能完全清楚?

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 = semitransparentBlack 设置颜色

关于 swift 4 : How to change UITableView cell color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55123920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com