LXReorderableCollectionViewFlowLayout 0.2.1

LXReorderableCollectionViewFlowLayout 0.2.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版本2017年5月

Stan Chang Khin Boon 维护。



  • Stan Chang Khin Boon

扩展了 UICollectionViewFlowLayout 以支持单元格重排,类似于 iBook 中的长按和拖动。

特性

LXReorderableCollectionViewFlowLayout 的目标是提供类似 iBook 的单元格重排功能。

  • 长按单元格以调用重排功能。
  • 调用重排功能时,从高亮状态淡出选择单元格到正常状态。
  • 拖动所选单元格到 desired 位置,其他单元格相应调整。通过委托方法调用回调。
  • 将选择单元格拖到边缘,根据滚动方向滚动到 desired 方向。
  • 释放以停止重排。

入门

Screenshot

  1. 使用 CocoaPods 或将 LXReorderableCollectionViewFlowLayout 文件夹拖动到项目中安装。

  2. 初始化/设置您的收藏视图以使用 LXReorderableCollectionViewFlowLayout

  3. 要支持重排功能的收藏视图控制器必须遵循 LXReorderableCollectionViewDataSource 协议。例如,

    - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath {
        id object = [mutableArray objectAtIndex:fromIndexPath.item];
        [mutableArray removeObjectAtIndex:fromIndexPath.item];
        [mutableArray insertObject:object atIndex:toIndexPath.item];
    }
    
  4. 您可以通过遵循 LXReorderableCollectionViewDelegateFlowLayout 方法来监听一些拖动事件。

  5. 根据您的需求设置您的收藏视图,运行并查看效果! :D

变更

2013年2月24日 (Luke Scott)

  • 删除 setUpGestureRecognizersOnCollectionView
  • 从委托方法中删除布局 (可从 collectionView 访问)
  • 重命名委托方法并分为数据源和委托
  • 在示例项目中添加数据源和委托示例

2013年2月23日 (Luke Scott)

  • 重构了一切,使其更易读/可维护
  • 已废弃 setUpGestureRecognizersOnCollectionView - 不再需要

要求

  • ARC
  • 推荐 iOS 6 及以上
  • Xcode 4.5 及以上

致谢

替代方案

许可证

LXReorderableCollectionViewFlowLayout在MIT许可证下可用