Skip to content

Instantly share code, notes, and snippets.

@lbrndnr
Created October 28, 2012 13:17
Show Gist options
  • Save lbrndnr/3968564 to your computer and use it in GitHub Desktop.
Save lbrndnr/3968564 to your computer and use it in GitHub Desktop.
Tweetbotish UITableView animation when reloading it
-(void)reloadData {
BOOL canAnimate = !self.visibleCells.count;
[self reloadData];
if (canAnimate) {
CABasicAnimation* revealAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
revealAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
revealAnimation.duration = 0.3f;
[revealAnimation setToValue:[NSNumber numberWithFloat:0.0f]];
[revealAnimation setFromValue:[NSNumber numberWithFloat:CGRectGetHeight(self.bounds)]];
revealAnimation.removedOnCompletion = YES;
for (UITableViewCell* cell in self.visibleCells) {
[cell.layer addAnimation:revealAnimation forKey:kCATransitionReveal];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment