关于tableView的两种动画 可单独拿出来使用,应该collectionView也能用
从左侧滑出的效果
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, 0, 0, 0, 1);//渐变
transform = CATransform3DTranslate(transform, -200, 0, 0);//左边水平移动
// transform = CATransform3DScale(transform, 0, 0, 0);//由小变大
cell.layer.transform = transform;
cell.layer.opacity = 0.0;
[UIView animateWithDuration:0.6 animations:^{
cell.layer.transform = CATransform3DIdentity;
cell.layer.opacity = 1;
}];
}
collectionView和tableView都能用这个方法 动画效果从远处飘过来
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
//设置动画时间为0.25秒,xy方向缩放的最终值为1
[UIView animateWithDuration:1.0f animations:^{
cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
}];
}

浙公网安备 33010602011771号