I'm looking for delayed row animation with RowAnimation
type 'bottom' and with specific duration for pushing rows to table view.
So far I found two options:
- Call
UITableView.reloadRows
insideUIView.transition
to set animation duration, callUIView.transition
insideTimer.scheduledTimer
to set the delay:
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)
}
This way animation duration is OK, but RowAnimation
type is reset (from '.bottom' I suppose to '.automatic').
- Use
CATransaction
for animation with duration, and call it insideTimer.scheduledTimer
to set the delay:
Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in
CATransaction.begin()
CATransaction.setAnimationDuration(1)
self.tableView.reloadRows(at: [indexPath], with: .bottom)
CATransaction.commit()
}
This way RowAnimation
type is OK, but animation duration is not respected.
How to set up properly either the RowAnimation
type not to be reset or the animation duration for CATransaction
with delay?