Animate [tableView reloadData]
A much simpler solution that doesn't require CoreAnimation.
Swift 3:
UIView.transition(with: self.view,
duration: 0.15,
options: [.curveEaseInOut, .transitionCrossDissolve],
animations: {
self.tableView.reloadRows(at: self.tableView.indexPathsForVisibleRows!, with: .none)
}, completion: nil)
[UITablewView reloadData:]
is not animatable. However, you may want to try reloading tableView by reloading all sections with animation.
NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [tableView numberOfSections])];
[self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationAutomatic];
OK, I lied. It may be animatable but it requires much knowledge about how QuartzCore Framework operates on UI components.
@import QuartzCore;
[self.tableView reloadData];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.fillMode = kCAFillModeForwards;
transition.duration = 0.6;
transition.subtype = kCATransitionFromTop;
[self.tableView.layer addAnimation:transition forKey:@"UITableViewReloadDataAnimationKey"];
Swift 4 solution with QuartzCore
import QuartzCore
tableView.reloadData()
let transition = CATransition()
transition.type = kCATransitionPush
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.fillMode = kCAFillModeForwards
transition.duration = 0.6
transition.subtype = kCATransitionFromBottom
tableView.layer.add(transition, forKey: "UITableViewReloadDataAnimationKey")
Swift 5
tableView.reloadData()
let transition = CATransition()
transition.type = .push
transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
transition.fillMode = .forwards
transition.duration = 0.6
transition.subtype = .fromBottom