UICollectionViewFlowLayout animation of a subclass of UICollectionViewLayoutAttributes frame changes

I have a subclass of UICollectionViewFlowLayout , and in this subclass I change the scope of UICollectionViewLayoutAttributes so that they look larger or smaller - depending on their position on the screen.

I am doing frame changes in layoutAttributesForElementsInRect : And returning it to layoutAttributesForItemAtIndexPath : I return YES in shouldInvalidateLayoutForBoundsChange :

Everything works well, but cells do not animate frame changes.

Am I missing something? Why are the changes not animating?

Thanks.

+6
source share
1 answer

solvable.

There is no animation function or anything like that, since changing the frames of the collection view elements inside your own custom stream (stream) simply cannot be animated.

The solution to this problem is to write an algorithm that calculates all the corresponding frames, which the layoutAttributesForElementsInRect: method ensures that setting the frame of an element will respectfully set another frame element, compensates for the added size or reduced size.

0
source

All Articles