Upvote:3

    let oldColor = cell.viewCell.backgroundColor
    UIView.animate(withDuration: 0.5, animations: {
        cell.viewCell.backgroundColor = UIColor.red
        }, completion: { _ in
            UIView.animate(withDuration: 0.5) {
                cell.viewCell.backgroundColor = oldColor
            }
    })

More Answer related to the Same Query

Upvote:2

fileprivate var color1 = UIColor.clear
fileprivate var color2 = UIColor.red
fileprivate func animateCell(_ cell: UITableViewCell) {

    UIView.animate(withDuration: 1.0, delay: 0.0, options: [.transitionCrossDissolve, .allowAnimatedContent], animations: {
        cell.contentView.backgroundColor = self.color2
    }) { (_) in
        UIView.animate(withDuration: 1.0, animations: {
            cell.contentView.backgroundColor = self.color1
        })
    }

}

Credit Goes to: stackoverflow.com

Related question with same questions but different answers