在UICollectionView中设置所有UICollectionViewCell的动画

Cry*_*tal 5 ios uicollectionview

我想知道在UICollectionView中为所有单元设置动画的好方法是什么.我正在尝试在UICollectionView中模拟编辑.所以我想要做的是收缩UICollectionViewCells的所有边界.所以我拥有的是:

- (IBAction)startEditingMode:(id)sender {
    [_items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:0];
        UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];

        [UIView animateWithDuration:0.25 animations:^{
            cell.layer.transform = CATransform3DMakeScale(0.9, 0.9, 1);
        }];
    }];
}
Run Code Online (Sandbox Code Playgroud)

它有效,但我不确定UICollectionView上是否有属性,或者更好的标准方式来做这样的事情.谢谢.

wL_*_*wL_ 0

你尝试过使用UICollectionView performBatchUpdates:吗?

就像是:

[collectionView performBatchUpdates:^{
    [_items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:0];
        UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
        cell.layer.transform = CATransform3DMakeScale(0.9, 0.9, 1);
    }];
} completion:^{}];
Run Code Online (Sandbox Code Playgroud)