带动画的UICollectionView reloadSections

Ser*_*gey 19 animation objective-c uicollectionview

我想用一些有趣的动画重新加载UICollectionView.在UITableView中有一个名为的方法reloadSections:withRowAnimation.但在UICollectionView中只有reloadSections.

如何自定义reloadSections动画?我肯定在App Store的应用程序中看到了这一点.

Fab*_*b1n 30

就这样做:

[self.collectionView performBatchUpdates:^{
    [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
Run Code Online (Sandbox Code Playgroud)


Mar*_*ges 22

Swift 3版本:

collectionView.performBatchUpdates({
    let indexSet = IndexSet(integer: 0)
    self.collectionView.reloadSections(indexSet)
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)

  • 没有泄漏,也不需要[弱自我].[weak self]仅用于创建循环依赖的长期闭包.这种关闭甚至都没有逃脱. (6认同)
  • 确切地说,它的非逃逸闭包所以不需要弱自我 (2认同)