Avoid animation of UICollectionView after reloadItemsAtIndexPaths

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

    extension UICollectionView {
        func reloadWithoutAnimation(){
            CATransaction.begin()
            CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
            self.reloadData()
            CATransaction.commit()
        }
    }
    

提交回复
热议问题