Custom UICollectionViewLayout to create a slick vertical sliding effect.
There is a sample Xcode project available with two examples. Just Build & Run.
To use the Custom layout in your projects just includes the AWCollectionViewSlidingDoorLayout.h and AWCollectionViewSlidingDoorLayout.m classes.
Import the Custom CollectionViewLayout
Create a new instance of the CollectionViewLayout and assign it to your collectionview
AWCollectionViewSlidingDoorLayout *slidingLayout = [[AWCollectionViewSlidingDoorLayout alloc] initWithMaxRatio:1.5 andMinRatio:6]; [collectionView setCollectionViewLayout:slidingLayout];
You will need to define ratio (width/height) values for active and inactive states. MaxRatio is the ratio of your active Cell and MinRatio the ratio of the inactive cells.
If you want to add custom animations to your UICollectionViewCell subviews overwrite the layoutSubviewsWithAttributes delegate and refer to the following code snippet
- Use AutoLayout when setting up your UICollectionViewCell nib to achieve the resize effect you want.
- Play aroud with the UIImageView ContentMode and the UILabel minimum scale
- Make sure your MaxRatio is bigger than your Images ratio to avoid a sudden jump during the resizing of the Cell