Skip to content

Instantly share code, notes, and snippets.

@titoaesj
Last active October 16, 2017 13:26
Show Gist options
  • Save titoaesj/81d9aa5214cd94444a1a79799dee7786 to your computer and use it in GitHub Desktop.
Save titoaesj/81d9aa5214cd94444a1a79799dee7786 to your computer and use it in GitHub Desktop.
Criando animação nas células da UITableView - iOS
override func viewWillAppear(animated: Bool) {
animateTable()
}
func animateTable() {
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.5, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: nil, 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