我有通过 XIB 包含用户定义单元格的表格。我的表格支持编辑模式以删除或重新排列单元格。
我已经实现了
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
现在,有没有办法在单元格处于“编辑模式”时更改单元格的背景?
最佳答案
我认为为此您需要两个委托(delegate)方法:
func tableView(UITableView, willBeginEditingRowAt: IndexPath)
Tells the delegate that the table view is about to go into editing mode.
和
func tableView(UITableView, didEndEditingRowAt: IndexPath?)
Tells the delegate that the table view has left editing mode.
您可以像这样实现每个委托(delegate)方法:
tableView.cellForRow(at: indexPath).backgroundColor = someColor
关于ios - Swift - 在编辑模式下更改表格单元格背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44486771/