Cool Animation In UITableView

by sisccr

Animation in iOS are the heart of the user experience. We can add cool animation with few lines of code. I would like to share a piece of UITableViewAnimation here.


After all the cells are displayed normally in table view. Create a simple function called AnimateTableView.

func animateTableView() {
        let cells = tableview.visibleCells
        let tableHeight = tableview.bounds.size.height
            $0.transform = CGAffineTransform(translationX: 0, y: tableHeight)
        var delayCounter = 0
        cells.forEach { (cell) in
            UIView.animate(withDuration: 1.75, delay: (Double(delayCounter) * 0.05), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: .curveEaseOut, animations: {
                cell.transform = CGAffineTransform.identity
            }, completion: nil)
            delayCounter += 1

Just call that function in viewWillAppear or whereEver you want the show the animation.