Avoid animation of UICollectionView after reloadItemsAtIndexPaths

后端 未结 9 1827
情深已故
情深已故 2020-12-04 06:07

UICollectionView animate items after reloadItemsAtIndexPaths is called (fade animation).

Is there a way to avoid this animation?

iOS 6

9条回答
  •  自闭症患者
    2020-12-04 06:11

    I wrote a category on UICollectionView to do just that. The trick is to disable all animations while reloading:

    if (!animated) {
        [CATransaction begin];
        [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
    }
    
    [self reloadItemsAtIndexPaths:indexPaths];
    
    if (!animated) {
        [CATransaction commit];
    }
    

提交回复
热议问题