Created
August 29, 2014 09:06
-
-
Save ltebean/eb609f09bef0ef30e9a3 to your computer and use it in GitHub Desktop.
tableview visible cells animation
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
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 i = 0; i < [cells count]; i++) { | |
UITableViewCell *cell = [cells objectAtIndex:i]; | |
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 i = 0; i < [cells count]; i++) { | |
UITableViewCell *cell = [cells objectAtIndex:i]; | |
[UIView animateWithDuration:1.2 delay:diff*i 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
Don't forget
[self.tableView reloadData];
💯