Skip to content

Instantly share code, notes, and snippets.

@dipkasyap
Created August 16, 2016 06:40
Show Gist options
  • Save dipkasyap/78da1f0d170429855c700a2d261dbc00 to your computer and use it in GitHub Desktop.
Save dipkasyap/78da1f0d170429855c700a2d261dbc00 to your computer and use it in GitHub Desktop.
Reloading table view with custom animation
func reload(TableViewWithAnimation tableView:UITableView, animationType:UIViewAnimationOptions){
UIView.transitionWithView(tableView,
duration:0,
options:animationType,
animations:{() -> Void in
tableView.hidden = true
tableView.reloadData()
},
completion: animateTable);
}
func animateTable(True :Bool) {
let cells = tableView.visibleCells
let tableHeight: CGFloat = tableView.bounds.size.height
let tableWidth:CGFloat = tableView.bounds.size.width
for i in cells {
let cell: UITableViewCell = i
cell.transform = CGAffineTransformMakeTranslation(-2*tableWidth, -2*tableHeight)
}
var index = 0
for a in cells {
let cell: UITableViewCell = a
UIView.animateWithDuration(1, delay: 0.05 * Double(index), usingSpringWithDamping:0.8, initialSpringVelocity: 0, options: .CurveEaseOut, animations: {
self.tableView.hidden = false
cell.transform = CGAffineTransformMakeTranslation(0, 0);
}){(check) in
// self.indicator.stopAnimating()
}
index += 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment