我正在创建一个任务列表。您可以通过滑动单元格并单击滑动按钮来标记任务并完成。 .destructive风格使细胞立即消失,这在这里看起来不太好。我想让它慢一点(可能先褪色而不是消失)。
我正在学习Swift,不知道该怎么做,也没有在网上找到任何小费。谁能帮助我?
这是我的功能:
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let markAsDone = UIContextualAction(style: .destructive, title: "DONE") { (doneAction, view, isSuccess) in
print("User marked task as done")
isSuccess(true)
}
markAsDone.backgroundColor = UIColor.lightGray
return UISwipeActionsConfiguration(actions: [markAsDone])
}
你可以尝试这样的事情,
tableView.beginUpdates()
tableView.deleteRows(at: indexPath, with: .fade) // Use your desired indexPath
tableView.endUpdates()