2015-03-21 3 views
4

Я хочу выполнить анимацию преобразования в UICollectionViewLayout. Хорошо, что достигается легко, но я не могу найти способ установить anchorPointUICollectionViewLayoutAttributes. Я хочу, чтобы выполнить открытие дверей и закрытия анимации в то время как вид коллекции элемент вставляетсяУстановить опорную точку в 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; 
} 

ответ

0

Там, кажется, не быть anchorPoint атрибутом в UICollectionViewLayoutAttributes, так что вам придется его подкласса, добавить свойство для anchorPoint и используйте applyLayoutAttributes по адресу UICollectionViewCell, чтобы установить значение anchorPoint на ячейку.

0

Если вам нужен более конкретный пример подкласса и добавления атрибутов, я предлагаю вам взглянуть на this tutorial

Смежные вопросы