Skip to content

Instantly share code, notes, and snippets.

@premedios
Created January 17, 2015 16:12
Show Gist options
  • Save premedios/d757e4f72f7887fe041b to your computer and use it in GitHub Desktop.
Save premedios/d757e4f72f7887fe041b to your computer and use it in GitHub Desktop.
// Make the table invisible, then reload its data
self.tableView.alpha = 0.0f;
[self.tableView reloadData];
// Store a delta timing variable so I can tweak the timing delay
// between each row’s animation and some additional
CGFloat diff = .05;
CGFloat tableHeight = self.tableView.bounds.size.height;
NSArray *cells = [self.tableView visibleCells];
// Iterate across the rows and translate them down off the screen
for (NSUInteger a = 0; a < [cells count]; a++) {
UITableViewCell *cell = [cells objectAtIndex:a];
if ([cell isKindOfClass:[UITableViewCell class]]) {
// Move each cell off the bottom of the screen by translating its Y position
cell.transform = CGAffineTransformMakeTranslation(0, tableHeight);
}
}
// Now that all rows are off the screen, make the tableview opaque again
self.tableView.alpha = 1.0f;
// Animate each row back into place
for (NSUInteger b = 0; b < [cells count]; b++) {
UITableViewCell *cell = [cells objectAtIndex:b];
[UIView animateWithDuration:1.6 delay:diff*b usingSpringWithDamping:0.77
initialSpringVelocity:0 options:0 animations:^{
cell.transform = CGAffineTransformMakeTranslation(0, 0);
} completion:NULL];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment