So, I have a UICollectionView where I insert new items.
I used the most of the suggestions from the Collection View Programming Guide - section "Making Insertion and Deletion Animations More Interesting"
Is there a way to adjust the animation time? (Maybe I just missed it in the docs, but couldn't find any info on this)
PS: If I could edit the curve that would be cool too. You know Ease-In-Out and so forth.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With