UICollectionView insertItem -> adjust animation time?

3 Solutions Collect From Internet About “UICollectionView insertItem -> adjust animation time?”

You can change any animation speed with CALayer. So for UICollectionView this looks like the following:

[self.collectionView.viewForBaselineLayout.layer setSpeed:0.1f];

And you can change back the original speed:

[self.collectionView.viewForBaselineLayout.layer setSpeed:1.0f];

For this to work you may need to import QuartzCore:

#import <QuartzCore/QuartzCore.h>

Or just do

[UIView animateWithDuration:0.5f animations:^(void) {
  [self.collectionView insertItemsAtIndexPaths:@[newIndexPath]];
}];

The animation duration will affect the internal duration of the collection view insertion animation.

You cannot adjust the animation with the Apple-provided layout methods. If you want to customize the animation you need to hide the item via attributes (just show and empty space), do your animation yourself and an at the end of the animation pop the item back in via attributes.

I asked a similar question about customizing the moving animation, but the consensus has been what I described. Animate yourself if you need to.

This question shows how to do a custom removal animation, customzing insertion should be similar: UICollectionView horizontal scrolling, deleting last item, animation not working