KSGallerySlidingCollectionView
is a collection view menu in the style of UltraVisual.
Reference from RPSlidingMenu.But we make some improve Which makes it a highly-customizable lightweight component.
- CollectionViewLayout subclass from FlowLayout directly.
- Better performance:we do not caculate layoutattributes of all Items.we only recaculate layoutattributes of rect that needed to display.
- Highly-customizable and lightweight.
see KSGallerySlidingCollectionViewDemo
Add pod 'KSGallerySlidingCollectionView'
to your Podfile
(see sample Xcode project in /KSGallerySlidingCollectionViewDemo)
-
Create a new file that inherits from
KSGallerySlidingCell
. overload the following method:- (void)layoutSubViewsWithPercent:(CGFloat)percentOfGrowth
You should do all the position and alpha change dule to the percentOfGrowth
-
In the ViewController,setup the CollectionView:
KSGallerySlidingLayout *layout = [[KSGallerySlidingLayout alloc] initWithDelegate:self]; layout.itemSize = CGSizeMake(CGRectGetWidth(self.collectionView.frame), HomeNewsCellCollapsedHeight); self.collectionView.collectionViewLayout = layout; [self.collectionView registerNib:[UINib nibWithNibName:@"HomeNewsCell" bundle:nil] forCellWithReuseIdentifier:@"HomeNewsCell"];
-
You can customize the featureHeight and collapsedHeight.
set the height after cell intilized:self.featureHeight = HomeNewsCellFeatureHeight; self.collapsedHeight = HomeNewsCellCollapsedHeight;
implement the KSGallerySlidingLayoutLayoutDelegate in the ViewController:
- (CGFloat)heightForFeatureCell
{
// return RPSlidingCellFeatureHeight;
return HomeNewsCellFeatureHeight;
}
- (CGFloat)heightForCollapsedCell
{
// return RPSlidingCellCollapsedHeight;
return HomeNewsCellCollapsedHeight;
}
-
Customize the cell animation when view scroll all you need to do is overload the following method in you cell,and do all the position and alpha change dule to the percentOfGrowth:
- (void)layoutSubViewsWithPercent:(CGFloat)percentOfGrowth
If you have any suggestions feel free to contact me.