Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🎉 🎉 🎉 🎉 🎉 让你轻松实现类似支付宝的拖拽重排功能, 支持各种自定义操作。

License

Notifications You must be signed in to change notification settings

lee18Cat/BMLongPressDragCellCollectionView

Repository files navigation

介绍

  • 本框架是一个让你轻松实现类似支付宝的拖拽重排功能,支持自定义,iOS8+,具体可查看代码。

CocoaPods 安装

pod 'BMLongPressDragCellCollectionView'
pod install
#import "BMLongPressDragCellCollectionView.h"

手动安装

  • 下载项目 「 clone https://github.com/liangdahong/BMLongPressDragCellCollectionView.git
  • BMLongPressDragCellCollectionView 文件夹下的全部内容拖拽到你的项目。

使用说明

  1. BMLongPressDragCellCollectionView 是继自 UICollectionView ,其使用方式和 UICollectionView 一致,只需要把 UICollectionView 修改为 BMLongPressDragCellCollectionView 即可【支持 Xib,StoryBoard】。
  2. 原来的 UICollectionViewDataSource 换为 BMLongPressDragCellCollectionViewDataSource
  3. 原来的 UICollectionViewDelegateFlowLayout 换为 BMLongPressDragCellCollectionViewDelegate
  4. 实现数据源方法,内部会使用此方法获取数据源,必须实现。
- (nullable NSArray *)dataSourceWithDragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView;

如下:

- (NSArray *)dataSourceWithDragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView {
 return self.dataSourceArray;
}
  1. 实现代理方法,当 Cell 有交换时调用,需要外面保存最新的数据源【如果有交换时,数据源已经更新】,必须实现。
- (void)dragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView newDataArrayAfterMove:(nullable NSArray *)newDataArray;

如下:

- (void)dragCellCollectionView:(BMLongPressDragCellCollectionView *)dragCellCollectionView newDataArrayAfterMove:(nullable NSArray *)newDataArray {
 self.dataSourceArray = [newDataArray mutableCopy];
}

图文演示

Xib或者 StoryBoard 中使用

  • Xib或者 StoryBoard 中只需要上面的 3 步就可以让你的 UICollectionView 完美支持拖拽重排了。

使用纯代码实现

  • 在纯代码实现中只需要上面的 3 步 就可以让你的 UICollectionView 完美支持拖拽重排了。

更多自定义方案

如果要做一些自定义的操作可以通过设置 BMLongPressDragCellCollectionView 的相关属性或者实现一些特定的协议方法来处理,可查看 BMLongPressDragCellCollectionView 的头文件和 BMLongPressDragCellCollectionViewDelegateBMLongPressDragCellCollectionViewDataSource 协议。

联系

  • 欢迎 issuesPR
  • 也可以添加微信 进微信交流群。

其他

  • 定个小目标 😂 2020年08月05日 纯 Swift 正在计划中...

感谢

相关推荐

License

BMLongPressDragCellCollectionView is released under the MIT license. See LICENSE for details.

About

🎉 🎉 🎉 🎉 🎉 让你轻松实现类似支付宝的拖拽重排功能, 支持各种自定义操作。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 96.3%
  • Swift 2.6%
  • Other 1.1%

AltStyle によって変換されたページ (->オリジナル) /