美文网首页iOS Development
Swift - tableview cell 从底部到顶部动画

Swift - tableview cell 从底部到顶部动画

作者: 71150ce14a00 | 来源:发表于2017-02-17 17:06 被阅读46次
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
}
}

相关文章

网友评论

    本文标题:Swift - tableview cell 从底部到顶部动画

    本文链接:https://www.haomeiwen.com/subject/nwjlwttx.html