Nin*_*nja 5 uiscrollview uianimation ios uicollectionview swift
我只是想在以编程方式滚动到项目时制作自定义动画。因此,当我不编写动画并按单元格默认使用时,不会消失,但是当我将scrolltoItem函数放入UIView.animate函数中时,最后一个单元格首先消失,然后scrollToItem动画。
在最上面的第二张图片中,位于独立游戏单元之前的collectionView首先消失,然后collectionView从独立游戏单元滚动到下一个
为什么会发生这种行为?为什么当我没有以我的方式有目的地对其进行动画处理,而只是使用animated = true func 调用scrollToItem 时,没有任何消除?如果有人知道细胞会发生什么,请给我一个线索。
UIView.animate(withDuration: 10, delay: 0, options: .curveEaseInOut, animations: {
self.appsCollectionView.scrollToItem(at: IndexPath(item: self.actualNumberOfTheCell, section: 0), at: .centeredHorizontally, animated: false)
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我认为你应该这样做self.view.layoutIfNeeded()
self.appsCollectionView.scrollToItem(at: IndexPath(item: self.actualNumberOfTheCell, section: 0), at: .centeredHorizontally, animated: false)
UIView.animate(withDuration: 10, delay: 0, options: .curveEaseInOut, animations: {
self.view.layoutIfNeeded()
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
希望它能起作用
| 归档时间: |
|
| 查看次数: |
2190 次 |
| 最近记录: |