I'm creating a task list. You can mark task and done by swiping the cell and clicking the swipe button. The .destructive style makes the cell disappear immediately which doesn't look good here. I'd like to make it a bit slower (could be fading first and than disappearing).
I'm learning Swift and have no idea how to do it and didn't find any tip on the internet. Could anyone help me?
Here's my func:
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])
}
You can try something like this,
tableView.beginUpdates()
tableView.deleteRows(at: indexPath, with: .fade) // Use your desired indexPath
tableView.endUpdates()