UITableView可以说是iOS开发中最常用的控件了,作为一个高逼格的开发者,肯定不想局限于其平淡无奇的滚动效果,这时候我们就想着往上面倒腾出一些比较有意思的特效,下面来看看如何给UITableViewCell加特效!!
我们需要用到得代理方法:
willDisplayCell,顾名思义,在cell即将显示的时候会调用此方法.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
添加动画
- (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"];}
最终效果,有兴趣的还可以研究更多的动画效果.