This UITableView extension works for Swift 4:
extension UITableView { func reloadDataWithAnimation(duration: TimeInterval, options: UIViewAnimationOptions) { UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: { self.alpha = 0 }, completion: nil) self.reloadData() UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: { self.alpha = 1 }, completion: nil) }
Usage: tableView.reloadDataWithAnimation(duration: 1.0, options: .curveLinear)
source share