2012-07-17 35 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。隨着表格滾動細胞的比例變得不透明。你真的可以在這裏做任何你想做的事情。