UICollectionViewLayoutAttributes

UICollectionViewLayoutAttributes

我想在UICollectionViewLayout中执行变换动画。好吧,这很容易实现,但是我找不到设置anchorPointUICollectionViewLayoutAttributes的方法。我想在插入收藏夹视图项目时执行开门和关门动画

-(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;
}

最佳答案

anchorPoint中似乎没有UICollectionViewLayoutAttributes属性,因此您必须对其进行子类化,为anchorPoint添加一个属性,并使用applyLayoutAttributes上的UICollectionViewCell设置单元格上的anchorPoint值。

09-27 04:35