首页 > 解决方案 > Animate UICollectionView contentInset adjustment

问题描述

Is there any way to animate the invalidateLayout() call on a UICollectionView layout? I have a collectionView with a custom layout, and a view that is animating on top of that collectionView. I would like to animate the repositioning of the cells in the collection view (much like a default UIScrollView implementation would do), but calling invalidateLayout() during an animation block repositions the cells with a fade animation, rather than an interpolation of the frames.

Is there any way to dictate the type of animation used in the layout change?

标签: iosswiftuicollectionviewuicollectionviewlayout

解决方案


I finally found the answer, and hope this helps someone else. The trick was simply to call collectionView.performBatchUpdtes(nil, completion: nil) inside the animation block.


推荐阅读