Sunday, 8 September 2013

Animate frame and layout change of UICollectionView

Animate frame and layout change of UICollectionView

I am trying to create an effect where I change the layout of my
UICollectionView while changing the frame size
Initially the collectionView layout presents a "thumbnail" gallery style
full screen.
After resizing the frame to a thin strip - I would like to present a "film
strip" style layout
both layouts independently work fine and as expected.
I tried code similar to this:
[UIView animateWithDuration:1
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.collectionview.frame = newFrame; // animate
the frame size
}
completion:^(BOOL finished) {
[self.collectionView.collectionViewLayout
invalidateLayout];
[self.collectionView setCollectionViewLayout:filmstriplayout
animated:YES]; // now set the new layout
}];
But it is looking very choppy and not resizing as expected.
Is there a way where I could change the collectionview layout and the
frame size simultaneously while animating the change?

No comments:

Post a Comment