Skip to content

Instantly share code, notes, and snippets.

@SaurabhPrajapati
Created December 31, 2019 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaurabhPrajapati/3a8fcf09c5a4db3d33c42ecb65856f67 to your computer and use it in GitHub Desktop.
Save SaurabhPrajapati/3a8fcf09c5a4db3d33c42ecb65856f67 to your computer and use it in GitHub Desktop.
extension UITableView {
func reloadAnimation() {
var visibleViews: [UIView] = visibleCells
for section in 0..<numberOfSections {
if let headerView = self.headerView(forSection: section) {
visibleViews.append(headerView)
}
if let footerView = self.footerView(forSection: section) {
visibleViews.append(footerView)
}
}
visibleViews = visibleViews.sorted(by: { $0.frame.origin.y < $1.frame.origin.y })
for view in visibleViews {
view.alpha = 0.0
var tx = CGAffineTransform.identity
tx = tx.translatedBy(x: 0, y: 25)
tx = tx.scaledBy(x: 0.95, y: 0.95)
view.transform = tx
view.layer.shouldRasterize = true
view.layer.rasterizationScale = UIScreen.main.scale
}
var delay: TimeInterval = 0
for view in visibleViews {
UIView.animate(withDuration: 0.75,
delay: delay,
usingSpringWithDamping: 0.6,
initialSpringVelocity: 0.0,
options: [], animations: {
view.alpha = 1
view.transform = CGAffineTransform.identity
}, completion: { _ in
view.layer.shouldRasterize = false
})
delay += 0.025
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment