iOS开发中如何给UITableViewCell添加动画

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

相关文章
相关标签/搜索