//給cell添加動畫
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath
{
//設(shè)置Cell的動畫效果為3D效果
//設(shè)置x和y的初始值為0.1;
cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
//x和y的最終值為1
[UIView animateWithDuration:1 animations:^{
cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
}];
}
只要把這幾行代碼加到tableView加載的那個界面里,就可以實現(xiàn)好看的動畫效果。
當(dāng)然,如果你了解3D動畫的幾個關(guān)鍵詞rotate,scale,translation的話,你可以替換上面的關(guān)鍵字,分別使用下面三種方法,注意我加粗的字體哦,
cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 0.1);
cell.layer.transform=CATransform3DMakeRotation(M_PI,0.1,0.1,0.1);
cell.layer.transform = CATransform3DMakeTranslation(<#CGFloat tx#>, <#CGFloat ty#>, <#CGFloat tz#>)
[UIView animateWithDuration:1 animations:^{
cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
}];//在block里執(zhí)行的是動畫執(zhí)行完后的效果,括號的參數(shù)可以隨便改改,看看效果吧,注意三個關(guān)鍵字,也就是你之前執(zhí)行的動畫要與執(zhí)行完之后的動畫是一個動畫,就是說你前后使用的關(guān)鍵字要一樣。