UICollection View animated cells in the original

I am presenting a view controller with uicollectionview. I want the cells to liven up from above.

My layout is a subclass of the flowlayout class, so I override this method:

- (UICollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewLayoutAttributes* attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:indexPath]; CGFloat height = [self collectionViewContentSize].height; attributes.transform3D = CATransform3DMakeTranslation(0, -height, 0); return attributes; } 

It almost works, but I see that apples (flashes) instantly appear on the screen before they come to life.

Any ideas why they appear in their final place before applying the conversion, and how can I prevent this?

+4
source share
1 answer

Instead of setting the transformation, change the center:

 - (UICollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewLayoutAttributes* attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:indexPath]; CGPoint c = attributes.center; cy -= self.collectionViewContentSize.height; attributes.center = c; return attributes; } 

Changing a transform can always cause visibility problems because it invalidates the frame property.

0
source

Source: https://habr.com/ru/post/1492139/


All Articles