0

I am using the following code:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
            let cell = CellView(style: UITableViewCellStyle.default , reuseIdentifier: nil)

            let selectView = UIView()
            selectView.backgroundColor = UIColor(patternImage: UIImage(named:"ScrollImageTop1")!)
            cell.selectedBackgroundView = selectView

            return cell

    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                let cell = tableView.cellForRow(at: indexPath) as! CellView
                remove(item: indexPath.item)
        }

    func remove(item : Int)
        {
                tableRows -= 1
                tableView1.deleteRows(at: [IndexPath(item: item, section: 0)], with: .top)
        }

I am unable to understand how to increase animation time for the cell deletion. Please help me with implementing the same here. Help is much appreciated. Thanks.

Enrik Qaz
  • 243
  • 4
  • 14

1 Answers1

0

How do I change duration for delete animation for cells in table view?

Well there is no official iOS API that allows changing that.

But you can try some workaround which is creating animations on the UIView update the table inside it including the desired animation duration.

you can try something like this

UIView.animate(withDuration: 1.0, delay: 0.0, options: .curveEaseIn, animations: {
self.tableView.beginUpdates()
 //remove cells or insert them 
self.tableView.endUpdates()
}) { finished in
    // code
}

Original answer.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Mohmmad S
  • 5,001
  • 4
  • 18
  • 50