ios - 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?
解决方案
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.
推荐阅读
- flutter - 仅当复选框被“选中”时才启用颤振按钮
- python-3.x - 在 Tensorflow 中为 cifar 的子类训练 NN:地图标签
- batch-file - 是否可以在没有消息的情况下暂停批处理脚本?
- javascript - 如果字符串不包含值
- android - 如何创建一个Android PopupWindow,它将在当前活动的任何内容之上弹出?
- autodesk-forge - 可靠地确定 BIM 360 项目的 Revit 版本
- android - SQLDelight 模式生成失败
- c++ - C++中指针的类型转换和类型转换
- c# - 如何确定 ExecuteReader 是否返回结果集
- rxjs - 确定导致 observable 完成的原因