流动效果的TableView展现实现
2016-03-30 本文已影响159人
89aa04642c48
代码地址:https://github.com/w11p3333/LLXAnimateTableview
效果如下:
主要实现:
func animationTable() {
self.tableView.reloadData()
let cells = tableView.visibleCells
let tableHeight: CGFloat = tableView.bounds.size.height
for i in cells {
let cell: UITableViewCell = i as UITableViewCell
cell.transform = CGAffineTransformMakeTranslation(0, tableHeight)
}
var index = 0
for a in cells {
let cell: UITableViewCell = a as UITableViewCell
UIView.animateWithDuration(1.0, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
cell.transform = CGAffineTransformMakeTranslation(0, 0);
}, completion: nil)
index += 1
}
}
然后在viewWillAppear中调用它