カスタム レイアウトを使用して、UICollectionViewCells を次のように配置しています。
これはうまくいきます。ここで、左下隅にあるボタンを押すと、次のように、すべてのセルがアニメーションでビューの中央に戻ります。
私はこれを機能させていますが、まったくアニメーション化していません。それはそのようにちょっとポップします。リロードアクションに使用しているコードは次のとおりです。
- (IBAction)animate:(id)sender {
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
}
私のレイアウトクラスには、次のlayoutAttributesForItemAtIndexPath
ようにセルの中心を調整する prepareLayout が呼び出されるたびに反転するフラグがあります。
- (UICollectionViewLayoutAttributes*) layoutAttributesForItemAtIndexPath:(NSIndexPath *)path {
UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:path];
attributes.size = CGSizeMake(ITEM_SIZEw, ITEM_SIZEh);
if (self.isCircle) {
attributes.center = CGPointMake(_center.x +_radius *
cosf(2 * path.item * M_PI / _cellCount),
_center.y + _radius *
sinf(2 * path.item * M_PI/ _cellCount));
} else {
attributes.center = [self collectionView].center;
}
return attributes;
}
ビューの中心にセルの動きをアニメーション化するにはどうすればよいですか?