我正在寻找“底部”RowAnimation类型的延迟行动画,并且具有将行推送到表格视图的特定持续时间。
到目前为止,我找到了两个选择:
UITableView.reloadRows内部调用UIView.transition设置动画时长,调用UIView.transition内部Timer.scheduledTimer设置延迟:
Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in
UIView.transition(with: self.tableView,
duration: 1.0,
animations: {
self.tableView.reloadRows(at: [indexPath], with: .bottom)
}, completion: nil)
}
这种方式动画持续时间是可以的,但RowAnimation类型被重置(我想从'.bottom'到'.automatic')。
- 用于
CATransaction具有持续时间的动画,并在内部调用它Timer.scheduledTimer来设置延迟:
Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in
CATransaction.begin()
CATransaction.setAnimationDuration(1)
self.tableView.reloadRows(at: [indexPath], with: .bottom)
CATransaction.commit()
}
这种方式RowAnimation类型是可以的,但不尊重动画持续时间。
如何正确设置RowAnimation不重置的类型或延迟的动画持续CATransaction时间?