重新加载没有动画 Swift 的集合视图

Ash*_*yan 3 uicollectionview uicollectionviewcell swift

如何在没有动画的情况下仅重新加载一个单元格。我试着用

horizontalItem.selectedType = horizontalItem.selectedType == .deselected ? .selected : .deselected
collectionView.reloadItems(at: [indexPath])
Run Code Online (Sandbox Code Playgroud)

并更改背景和标题颜色,但更改为动画。

Kes*_*Rai 10

你可以使用performWithoutAnimation方法UIView

 UIView.performWithoutAnimation {
    collectionView.reloadItems(at: [indexPath])
 }
Run Code Online (Sandbox Code Playgroud)