WDragableMenu is able reorder the position of item by drag and drop action. WDragableMenu also provide two sections for user, user able to add/remove item to/from first section.
Clone the repo, and run pod install at Example directory.
At First, need to init WDragableMenu class and set delegate
- (WDragableMenu *)menuVC {
if (!_menuVC)
{
_menuVC = [[WDragableMenu alloc] init];
[_menuVC setTypeMenu:ReoderAndEditable];
[_menuVC setIsCellAnimationEnabled:NO];
[_menuVC setDragableMenuDelegate:self];
}
return _menuVC;
}private lazy var menuVC: WDragableMenu = {
let menuVC = WDragableMenu()
menuVC.typeMenu = OnlyReorder
menuVC.dragableMenuDelegate = self
return menuVC
}()@required
-
- (NSInteger)totalItemsInPrimarySection- Delegate to get total items to display at primary section -
- (nonnull NSString *)getTitleForCellInPrimarySection:(NSInteger)selectedItem- Delegate to get what text is going to display for menu cell at first section -
- (void)userUpdatedMenuSequence- to notify user when the sequence of menu is changed -
- (void)tapOnMenuItem:(NSInteger)selectedIndex- delegate action when click on menu item -
- (void)updateSequenceOfArrayWithOriginalIndex:(NSInteger)originalIndex withDestinationIndex:(NSInteger) destinationIndex- delegate to update the order of array in first section : reorder menu action is triggered
@optional - Is needed WHEN WDragableMenuType is ReoderAndEditable
-
- (NSInteger)totalItemsInSecondarySection- delegate to get total items display at second section -
- (nonnull NSString *)getTitleForCellInSecondarySection:(NSInteger)selectedItem- delegate to get what text is going to display for menu cell at second section -
- (void)addItemWithSelectedIndex:(NSInteger)selectedIndex- delegate to add menu item from second second to first section -
- (void)removeItemWithSelectedIndex:(NSInteger)selectedIndex- delegate to remove menu item from first section
@property (nonatomic, assign) WDragableMenuType typeMenu;
A enum value to decide how collectionMenu to display
OnlyReoder - there's one section of menu to display, only able to reoder the sequence ReoderAndEditable - there's two sections of menu to display, able to reoder the sequence and add/remove for menu sequence
Default value is "OnlyReoder" if do not set any value for it
@property (nonatomic) NSInteger numItemsFreeze;
numItemsFreeze provided a control to app to decide how many items of first section to be freezed. Default is first two items
Example:
self.numItemsFreeze = 3;@property (nonatomic) NSInteger numItemsinRow;
numItemsinRow provided a control to display how many items in one row. Default is 4
Example:
self.numItemsinRow = 3;@property (nonatomic, assign) BOOL isCellAnimationEnabled;
isCellAnimationEnabled is a value to control animation for menuitem. Default value is YES
Example:
self.isCellAnimationEnabled = NO;https://mobikul.com/ios-longpress-drag-and-drop-using-uicollectionview-with-animation/
WDragableMenu is available under the MIT license. See the LICENSE file for more info.
