-
Notifications
You must be signed in to change notification settings - Fork 765
Collection View动画
戴铭 edited this page Mar 4, 2015
·
1 revision
- 计算cells的动画,collection view 需通过initialLayoutAttributesForAppearingItemAtIndexPath:和finalLayoutAttributesForAppearingItemAtIndexPath:方法询问布局对象,获得最初和最后的属性。下面是实现cells从屏幕底部发射并且旋转飞到对应位置
- (UICollectionViewLayoutAttributes*)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath
{
UICollectionViewLayoutAttributes *attr = [self layoutAttributesForItemAtIndexPath:itemIndexPath];
attr.transform = CGAffineTransformRotate(CGAffineTransformMakeScale(0.2, 0.2), M_PI);
attr.center = CGPointMake(CGRectGetMidX(self.collectionView.bounds), CGRectGetMaxY(self.collectionView.bounds));
return attr;
}
finalLayoutAttributesForAppearingItemAtIndexPath: 方法中,除了设定了不同的 transform 以外,其他都很相似。
- prepareLayout
- prepareForCollectionViewUpdates:
- finalizeCollectionViewUpdates
- prepareForAnimatedBoundsChange:
- finalizeAnimatedBoundsChange
- shouldInvalidateLayoutForBoundsChange: