I have sub classed UICollectionViewFlowLayout, and in that sub class, I'm changing the UICollectionViewLayoutAttributes frames, so that they would appear larger or smaller - depending on their position on screen.

I'm performing the frame changes in layoutAttributesForElementsInRect: And as well returning it in layoutAttributesForItemAtIndexPath: I'm returning YES in shouldInvalidateLayoutForBoundsChange:

All is working well, but the cells do not animate the changes of the frame.

Am i missing Something? Why are the changes are not being animated?

Thanks.

有帮助吗?

解决方案

SOLVED.

There is no "animation function", or anything similar, since changing the frames of items of a collection view inside your own custom (flow) lay out just can't be animated.

The solution to the problem is writing an algorithm that calculates all the relevant frames that the method layoutAttributesForElementsInRect: provides, so that setting the frame of an item will respectfully set another item's frame an will compensate for the added size, or reduced size.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top