簡體   English   中英

如何使用UISwipeActionsConfiguration設置刪除單元格的延遲?

[英]How to set the delay in deleting cell with UISwipeActionsConfiguration?

我正在創建一個任務列表。 您可以通過滑動單元格並單擊滑動按鈕來標記任務和完成。 .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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM