Search code examples
objective-ciphoneuitableviewcocoa-touchcore-animation

Animating a Uitableviewcell


Tweetbot has some cool animations added to UITableViewCell's when swiped right that eventually reveal the conversation which got me curious: how do you animate a UITableViewCell to move it away from the normal frame of the tableview?

Also, how might you animate other views that are on top of the tablecell? Like a UIActivityMonitor or fading in and out a button?

I am not looking for answers for when it enters editing mode, or is selected, but rather in general. Thanks Guys.


Solution

  • CGPoint location = [recognizer locationInView:tblview];
    NSIndexPath* indexPath = [tblAim indexPathForRowAtPoint:location];
    
    ProjectCell *cell = (ProjectCell *) [tblAim cellForRowAtIndexPath:indexPath];
    
    if(cell.frame.origin.x!=0)
    [UIView animateWithDuration:0.3 animations:^{  [cell setFrame:CGRectMake(0,cell.frame.origin.y, 320, 60 )];} completion:^(BOOL finish){
    [UIView animateWithDuration:0.1 animations:^{[cell setFrame:CGRectMake(0-10,cell.frame.origin.y, 320, 60 )];} completion:^(BOOL finish){
    [UIView animateWithDuration:0.1 animations:^{[cell setFrame:CGRectMake(0,cell.frame.origin.y, 320, 60 )];}];
                    }];
                }];