gpt4 book ai didi

swift - 更改空表格 View 单元格的备用单元格背景颜色

转载 作者:行者123 更新时间:2023-11-30 12:20:25 26 4
gpt4 key购买 nike

我已经在 swift4 中以编程方式创建了一个 tableview Controller 。我的观点目前看起来像这样 enter image description here

我想要在未使用的 TableView 单元格中使用图像中标记的替代灰色。我可以更改使用的 TableView 单元格的替代颜色。非常感谢任何帮助。

最佳答案

您是否在 tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell: 中尝试过此操作:

if indexPath.row % 2 == 0 {
cell.backgroundColor = UIColor.lightGray
} else {
cell.backgroundColor = UIColor.white
}

这对我有用。我希望这也适合您。

关于swift - 更改空表格 View 单元格的备用单元格背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44858121/

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