Giter VIP home page Giter VIP logo

afmslidingcell's Introduction

AFMSlidingCell

CI Status Version License Platform

AFMSlidingCell is UITableViewCell subclass for showing any kind of buttons underneath the cell, revealable by swipe. It is a common way of displaying any cell-related actions (e.g. deletion) without overloading default UI.

Animated Example

AFMSlidingCell supports up to two differently sized UIButtons added to the cell's right side and can be used both directly from the Interface Builder and as a superclass for custom cell.

Usage

AFMSlidingCell can be used directly from the Interface Builder - just set UITableViewCell's class to AFMSlidingCell in Identity inspector tab.

Most common usage way is creating custom UITableViewCell. Simply subclass AFMSlidingCell instead of UITableViewCell and you're ready to go!

After dequeuing your cell, you can add UIButton:

AFMSlidingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AFMSlidingCell" forIndexPath:indexPath];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundColor:[UIColor greenColor]];
[cell addFirstButton:button withWidth:42.0 withTappedBlock:^(AFMSlidingCell *cell) {
  NSLog(@"Cell tapped");
}];

You can add any UIButton of any type, configure its states, images, etc.. Two buttons may be added in total:

[cell addFirstButton:firstButton withWidth:23.0 withTappedBlock:^(AFMSlidingCell *cell) {
  NSLog(@"First button tapped");
}];
[cell addSecondButton:button withWidth:42.0 withTappedBlock:^(AFMSlidingCell *cell) {
  NSLog(@"Second tapped");
}];

In case you want to add only one UIButton, there is no difference whether you add it as a first or as a second button.

You get additional control over your cell, e.g. it possible to show or hide added buttons programmatically:

[cell showButtonViewAnimated:YES];
[cell hideButtonViewAnimated:NO];

AFMSlidingCellDelegate can be used to get callbacks on button show/hide, as well as to forbid button showing for particular cells:

- (BOOL)shouldAllowShowingButtonsForCell:(AFMSlidingCell *)cell
{
  if (cell == self.forbiddenCell)
    return NO;
  return YES;
}

Requirements

iOS 7 and up.

Installation

AFMSlidingCell is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AFMSlidingCell'

Contact person

Artjoms Haleckis, [email protected]

License

AFMSlidingCell is available under the MIT license. See the LICENSE file for more info.

afmslidingcell's People

Watchers

 avatar  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.