【问题标题】:How do I change duration for delete animation for cells in table view? [duplicate]如何更改表格视图中单元格的删除动画持续时间? [复制]
【发布时间】:2018-10-22 07:28:19
【问题描述】:

我正在使用以下代码:

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)
        }

我无法理解如何增加单元格删除的动画时间。请帮助我在这里实施相同的操作。非常感谢您的帮助。谢谢。

【问题讨论】:

标签: ios swift xcode


【解决方案1】:

如何更改表格视图中单元格的删除动画持续时间?

好吧,没有官方的 iOS API 可以改变它。

但是您可以尝试一些解决方法,即在 UIView 上创建动画 更新其中的表格,包括所需的动画持续时间。

你可以试试这样的

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
}

原创answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-14
    • 2021-12-09
    • 1970-01-01
    • 2019-02-27
    相关资源
    最近更新 更多