Skip to content

Instantly share code, notes, and snippets.

@wleii
Created February 24, 2016 06:40
Show Gist options
  • Save wleii/93d7ce78a476ecb309b5 to your computer and use it in GitHub Desktop.
Save wleii/93d7ce78a476ecb309b5 to your computer and use it in GitHub Desktop.
A Simple TableViewCell Appear Animation
override func viewWillAppear(animated: Bool) {
animateTable()
}
func animateTable() {
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment