Giter VIP home page Giter VIP logo

drcellslidegesturerecognizer's Introduction

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.

drcellslidegesturerecognizer's People

Watchers

Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.