Created
December 31, 2019 06:39
-
-
Save SaurabhPrajapati/3a8fcf09c5a4db3d33c42ecb65856f67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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