UITableView能夠說是iOS開發中最經常使用的控件了,做爲一個高逼格的開發者,確定不想侷限於其平淡無奇的滾動效果,這時候咱們就想着往上面倒騰出一些比較有意思的特效,下面來看看如何給UITableViewCell加特效!!動畫
咱們須要用到得代理方法:spa
willDisplayCell,顧名思義,在cell即將顯示的時候會調用此方法.代理
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
添加動畫code
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { SDShotCell *shotCell = (SDShotCell *) cell; CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; scaleAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1)]; scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)]; scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; [shotCell.layer addAnimation:scaleAnimation forKey:@"transform"]; }
最終效果,有興趣的還能夠研究更多的動畫效果.orm