• This repository has been archived on 24/Aug/2020
  • Stars
    star
    522
  • Rank 84,811 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make your cells actionable through swipes

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

  • UITableView/UITableViewCell class agnostic.
  • Setup multiple actions for multiple cell fractions.
  • Fully customizable.
  • Block-driven.

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:

  • behavior: how the action will behave once triggered by the user. Possible values:
    • DRCellSlideActionPullBehavior: the cell returns to its original position.
    • DRCellSlideActionPushBehavior: the cell is pushed to the edge of the table.
  • icon: the image to be displayed for the action.
  • iconMargin: the margin for the icon.
  • activeColor: the color of icon when the action is active.
  • inactiveColor: the color of icon when the action is inactive.
  • activeBackgroundColor: the background color when the action is active.
  • inactiveBackgroundColor: the background color when the action is inactive.
  • elasticity: the amount of elastic resistence for the cell to be dragged.
  • willTriggerBlock: block that's triggered when the cell is about to behave accordingly to its behavior property.
  • didTriggerBlock: block that's triggered when the cell has already behaved accordingly to its behavior property. Here you should perform the main task for the cell action.
  • didChangeStateBlock: block that's triggered then the action reaches its active/unactive state.

License

DRCellSlideGestureRecognizer is available under the MIT license.