0
我在ViewController中有一个tableView,我只想在用户单击单元格中的Edit按钮时更改单元格背景颜色。单击编辑按钮时更改单元格颜色
我做了什么至今
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "taskcell", for: indexPath as IndexPath) as! taskListCell
cell.backgroundColor = colorMediumGreen
// Configure the cell…
let tableData = self.tableData[indexPath.row]
cell.duration.text = tableData[""] as? String
cell.taskDetail.text = tableData[""] as? String
return cell
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let editAction = UITableViewRowAction(style: .normal, title: "Erledigt") { (rowAction, indexPath) in
}
editAction.backgroundColor = .red
return [editAction]
}
刚刚获得与IndexPath'的'帮助小区和更新''editAction该小区。 –
@DharmeshKheni:你能解释一下吗? – SwiftUser