KSGallerySlidingCollectionView 0.0.1

KSGallerySlidingCollectionView 0.0.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年4月

btxkenshin 维护。



  • 作者:
  • btxkenshin

KSGallerySlidingCollectionView 是采用 UltraVisual 风格的集合视图菜单。

image

参考自 RPSlidingMenu,但我们进行了一些改进,使其成为一个高度可定制、轻量级的组件。

描述

  1. 直接从 FlowLayout 继承自 CollectionViewLayout 子类。
  2. 更好的性能:我们不计算所有项的布局属性。我们只重新计算需要显示的矩形区域的布局属性。
  3. 高度可定制且轻量级。

演示

KSGallerySlidingCollectionViewDemo

安装

使用

(参见 /KSGallerySlidingCollectionViewDemo 中的示例 Xcode 项目)

  1. 创建一个继承自 KSGallerySlidingCell 的新文件。重写以下方法

    - (void)layoutSubViewsWithPercent:(CGFloat)percentOfGrowth
    

    您应该对所有位置和 alpha 变化进行所有处理,基于 percentOfGrowth 百分比

  2. 在 ViewController 中,设置 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"];
    

高级定制

  1. 您可以自定义 featureHeight 和 collapsedHeight。
    在初始化 cell 的高度后设置它

    self.featureHeight = HomeNewsCellFeatureHeight;
    self.collapsedHeight = HomeNewsCellCollapsedHeight;
    

    在 ViewController 中实现 KSGallerySlidingLayoutLayoutDelegate

    - (CGFloat)heightForFeatureCell
    {
        //    return RPSlidingCellFeatureHeight;
        return HomeNewsCellFeatureHeight;
    }
    
    - (CGFloat)heightForCollapsedCell
    {
        //    return RPSlidingCellCollapsedHeight;
        return HomeNewsCellCollapsedHeight;
    }
    
  2. 自定义当视图滚动时的 cell 动画。您需要在您的 cell 中重写以下方法,并基于 percentOfGrowth 百分比进行所有位置和 alpha 变化处理

    - (void)layoutSubViewsWithPercent:(CGFloat)percentOfGrowth
    

注意

如果您有任何建议,请随时联系我。