我使用的是自定义布局来定位我的UICollectionViewCells像这样:我如何可以移动(动画)UICollectionView细胞和出圆形的[PICS]
这个伟大的工程。现在,当我按在左下角的按钮,我想有所有的细胞兴致勃勃地返回到视图的中心,就像这样:
我种有这方面的工作,但它根本不是动画。它只是那种流行的方式。下面是我使用的重载动作的代码:
- (IBAction)animate:(id)sender {
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
}
而在我的布局类的,我有我的每个prepareLayout被调用时,调节细胞的layoutAttributesForItemAtIndexPath
这样的中心翻转的标志:
- (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;
}
如何将单元格的运动动画化回视图的中心?
感谢您的回答,但没有骰子。仍然没有动画。 – Westley