2012-07-17 100 views
3

我知道有默认的UITableViewRowAnimation选项,但有没有办法创建我自己的动画?如果是这样,他们的教程是在这个?UITableViewRowAnimation自定义动画

我希望我的细胞能够向用户变焦,然后飞离屏幕。

我似乎无法找到太多有关这...

+0

可能的重复: pasawaya 2012-07-17 03:02:29

+2

也许是重复的,但仍然需要找到答案。 – 2012-07-17 03:19:16

回答

0

一种方法是在willDisplayCell,您可以访问的UIView/CAAnimation API的存在。示例:

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //1. Define the initial state (Before the animation) 
    cell.layer.shadowColor = [[UIColor blackColor]CGColor]; 
    cell.layer.shadowOffset = CGSizeMake(10, 10); 
    cell.alpha = 0; 
    cell.transform = CGAffineTransformMakeScale(0.85, 0.85); 

    //2. Define the final state (After the animation) and commit the animation 
    [UIView beginAnimations:@"scale" context:NULL]; 
    [UIView setAnimationDuration:0.5]; 
    cell.transform = CGAffineTransformIdentity; 
    cell.alpha = 1; 
    cell.layer.shadowOffset = CGSizeMake(0, 0); 
    [UIView commitAnimations]; 
} 

这是应用于单元格的简单“比例”,阴影和alpha-in。随着表格滚动细胞的比例变得不透明。你真的可以在这里做任何你想做的事情。