Created
October 28, 2012 13:17
-
-
Save lbrndnr/3968564 to your computer and use it in GitHub Desktop.
Tweetbotish UITableView animation when reloading it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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