我想在 UICollectionViewLayout
中执行转换动画。好吧,这很容易实现,但我找不到设置 UICollectionViewLayoutAttributes
的 anchorPoint
的方法。我想在插入 Collection View 项时执行开门和关门动画
-(UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath{
UICollectionViewLayoutAttributes *attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:itemIndexPath];
attributes.alpha = 1.0;
CGFloat progress = 0.0;
CATransform3D transform = CATransform3DIdentity;
transform.m34 = -1.0/500.0;
CGFloat angle = (1 - progress) * M_PI_2;
transform = CATransform3DRotate(transform, angle, 0, 1, 0 );
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:itemIndexPath];
cell.hidden = YES;
attributes.transform3D = transform;
return attributes;
}
最佳答案
UICollectionViewLayoutAttributes
中似乎没有anchorPoint
属性,因此您必须对其进行子类化,为anchorPoint
添加一个属性> 并使用 UICollectionViewCell
上的 applyLayoutAttributes
设置单元格上的 anchorPoint
值。
关于ios - 在 UICollectionViewLayoutAttributes 中设置 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29181499/