你的位置:首页 > 软件开发 > 操作系统 > 【推荐】iOS集合视图的可重新排序的layout

【推荐】iOS集合视图的可重新排序的layout

发布时间:2016-02-22 01:00:06
在实际项目中你或许会遇到在一个集合视图中移动一项到另外一个位置,那么此时我们需要对视图中的元素进行重新排序,今天推荐一个很好用的第三方类LXReorderableCollectionViewFlowLayout【点此链接进入GITHUB】下面附上实现代码//// LXReorde ...

  在实际项目中你或许会遇到在一个集合视图中移动一项到另外一个位置,那么此时我们需要对视图中的元素进行重新排序,今天推荐一个很好用的第三方类LXReorderableCollectionViewFlowLayout【点此链接进入GITHUB

下面附上实现代码

【推荐】iOS集合视图的可重新排序的layout【推荐】iOS集合视图的可重新排序的layout
//// LXReorderableCollectionViewFlowLayout.h//// Created by Stan Chang Khin Boon on 1/10/12.// Copyright (c) 2012 d--buzz. All rights reserved.//#import <UIKit/UIKit.h>@interface LXReorderableCollectionViewFlowLayout : UICollectionViewFlowLayout <UIGestureRecognizerDelegate>@property (assign, nonatomic) CGFloat scrollingSpeed;@property (assign, nonatomic) UIEdgeInsets scrollingTriggerEdgeInsets;@property (strong, nonatomic, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer;@property (strong, nonatomic, readonly) UIPanGestureRecognizer *panGestureRecognizer;- (void)setUpGestureRecognizersOnCollectionView __attribute__((deprecated("Calls to setUpGestureRecognizersOnCollectionView method are not longer needed as setup are done automatically through KVO.")));@end@protocol LXReorderableCollectionViewDataSource <UICollectionViewDataSource>@optional- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath;- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath didMoveToIndexPath:(NSIndexPath *)toIndexPath;- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath;- (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath canMoveToIndexPath:(NSIndexPath *)toIndexPath;@end@protocol LXReorderableCollectionViewDelegateFlowLayout <UICollectionViewDelegateFlowLayout>@optional- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;@end

原标题:【推荐】iOS集合视图的可重新排序的layout

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。