Swift - tableview cell 从底部到顶部动画
2017-02-17 本文已影响46人
71150ce14a00
func animateTable() {
masterTableView.reloadData()
let cells = masterTableView.visibleCells
let tableHeight = masterTableView.bounds.size.height
// move all cells to the bottom of the screen
for cell in cells {
cell.transform = CGAffineTransform(translationX: 0, y: tableHeight)
}
// move all cells from bottom to the right place
var index = 0
for cell in cells {
UIView.animate(withDuration: duration, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
cell.transform = CGAffineTransform(translationX: 0, y: 0)
}, completion: nil)
index += 1
}
}