在UICollectionViewLayoutAttributes中设置锚点

时间:2015-03-21 10:11:24

标签: ios uicollectionview uicollectionviewlayout

我想在UICollectionViewLayout中执行变换动画。好吧,这很容易实现,但我找不到设置anchorPoint UICollectionViewLayoutAttributes的方法。我想在插入集合视图项目时执行门打开和关闭动画

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

1 个答案:

答案 0 :(得分:0)

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