Avoid animation of UICollectionView after reloadItemsAtIndexPaths

后端 未结 9 1828
情深已故
情深已故 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:24

    - (void)reloadCollectionViewAnimated:(BOOL)animated  {
    
        if (animated) {
            [self.collectionView performBatchUpdates:^{
                [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
            } completion:^(BOOL finished) {
    
            }];
        } else {
            [CATransaction begin];
            [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
            [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
            [CATransaction commit];
        }
    
    }
    

提交回复
热议问题