ios如何给TableView或者CollectionView的cell添加简单动画
更新:HHH   时间:2023-1-7


这篇文章主要介绍ios如何给TableView或者CollectionView的cell添加简单动画,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

给TableView或者CollectionView的cell添加简单动画

只要在willDisplayCell方法中对将要显示的cell做动画即可:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath{ 

  NSArray *array = tableView.indexPathsForVisibleRows; 
 
  NSIndexPath *firstIndexPath = array[0]; 
  //设置anchorPoint 

  cell.layer.anchorPoint = CGPointMake(0, 0.5); 
   //为了防止cell视图移动,重新把cell放回原来的位置 
  cell.layer.position = CGPointMake(0, cell.layer.position.y);  
 
  //设置cell 按照z轴旋转90度,注意是弧度 
  if (firstIndexPath.row < indexPath.row) { 
       cell.layer.transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1.0); 
 
  }else{ 
 
    cell.layer.transform = CATransform3DMakeRotation(- M_PI_2, 0, 0, 1.0); 
 
  }

以上是“ios如何给TableView或者CollectionView的cell添加简单动画”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注天达云行业资讯频道!

返回web开发教程...