davdroman / DRCellSlideGestureRecognizer

Make your cells actionable through swipes
MIT License
519 stars 45 forks source link

THIS PROJECT IS NO LONGER MAINTAINED. HERE ARE SOME SUITABLE ALTERNATIVES:


DRCellSlideGestureRecognizer

GIF 1

Note: this library comes out as an abstraction of former PDGestureTableView's cell swiping logic. Since it's based on UIPanGestureRecognizer class, now there's a total independency on which UITableView and UITableViewCell classes it can interact with.

Features

Installation

CocoaPods

pod 'DRCellSlideGestureRecognizer'

Manual

Drag and copy all files in the DRCellSlideGestureRecognizer folder into your project.

At a glance

Setting up actions

Setting up an action is really simple, although you'll need a DRCellSlideGestureRecognizer instance to add them to first:

DRCellSlideGestureRecognizer *gestureRecognizer = [DRCellSlideGestureRecognizer new];

Then, simply instantiate DRCellSlideAction like this:

DRCellSlideAction *action = [DRCellSlideAction actionForFraction:0.25];
action.behavior = DRCellSlideActionPushBehavior;
action.icon = [UIImage imageNamed:@"imageName"];

Note: fraction determines the part of the cell to where the action will become active and ready to be triggered.

And finally, add the action to the gesture recognizer, and the gesture recognizer to the cell:

[gestureRecognizer addActions:action];
[cell addGestureRecognizer:gestureRecognizer];

Note: the given instructions should be performed inside tableView:cellForRowAtIndexPath: method.

Customizing actions

There are multiple DRCellSlideAction properties available for you to customize the appearence and interactivity of the cell:

License

DRCellSlideGestureRecognizer is available under the MIT license.