iOS 7 のスプリングボードと同様に、削除をアニメーション化する方法を見つけようとしていますUICollectionViewCell。削除されたセルは縮小して無になり、残りのセルがスライドしてその場所を埋める必要があります (スライドが重要な部分です)。私が試してみました:
• 次のように、各セルのフレームを前のセルのフレームに設定します。
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
CGRect rect = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i - 1 inSection:0]].frame;
[UIView animateWithDuration:0.2 animations:^{
cell.frame = rect;
}];
しかし、細胞はまったく動かなかったので、これはうまくいきませんでした。
• 次の両方:
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
と
[UIView animateWithDuration:0.2 animations:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
}];
しかし、これらはセルをスライドではなく、必要なスポットにクロスフェードさせます。
また、次を使用するこのプロジェクトも見つけました。
for (int i = index+1; i<[items count]; i++) {
SEMenuItem *item = [items objectAtIndex:i];
[UIView animateWithDuration:0.2 animations:^{
if (i < index + remainingNumberOfItemsInPage) {
int intVal = item.frame.origin.x;
if (intVal %3== 0)
[item setFrame:CGRectMake(item.frame.origin.x+2*item.frame.size.width, item.frame.origin.y-item.frame.size.height-5, item.frame.size.width, item.frame.size.height)];
else
[item setFrame:CGRectMake(item.frame.origin.x-item.frame.size.width, item.frame.origin.y, item.frame.size.width, item.frame.size.height)];
}
[item updateTag:item.tag-1];
}];
}
しかし、それはUICollectionView私には役に立たないので、そうではありません。
注:念のため、iPadでこれを行っています。
何か案は?