Giter Site home page Giter Site logo

coofree / zlswipeableview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liangwei518/zlswipeableview

0.0 2.0 0.0 5.82 MB

A simple view for building card like interface like Tinder and Potluck.

License: MIT License

Ruby 2.62% Objective-C 97.38%

zlswipeableview's Introduction

ZLSwipeableView

Gitter A simple view for building card like interface like Tinder and Potluck. ZLSwipeableView was originally developed for Murmur.

Preview

###Swipe swipe ###Swipe Cancel cancel ###Swipe Programmatically swipeLeft ###Swipe Programmatically II swipeLeftRight

CocoaPods

You can install ZLSwipeableView through CocoaPods adding the following to your Podfile:

pod 'ZLSwipeableView'

Usage

Check out the demo app for an example.

ZLSwipeableView can be added to storyboard or initialized programmatically:

ZLSwipeableView *swipeableView = [[ZLSwipeableView alloc] initWithFrame:self.view.frame];
[self.view addSubview:swipeableView];

A ZLSwipeableView must have an object that implements ZLSwipeableViewDataSource to act as a data source. ZLSwipeableView will prefetch three views in advance to animate them.

// required data source
self.swipeableView.dataSource = self;

#pragma mark - ZLSwipeableViewDataSource
- (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
  return [[UIView alloc] init];
}

A ZLSwipeableView can have an optional delegate to receive callback.

// optional delegate
self.swipeableView.delegate = self;

#pragma mark - ZLSwipeableViewDelegate
- (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeLeft:(UIView *)view {
    NSLog(@"did swipe left");
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeRight:(UIView *)view {
    NSLog(@"did swipe right");
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didCancelSwipe:(UIView *)view {
  NSLog(@"did cancel swipe");
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didStartSwipingView:(UIView *)view atLocation:(CGPoint)location {
    NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView swipingView:(UIView *)view atLocation:(CGPoint)location  translation:(CGPoint)translation {
	NSLog(@"swiping at location: x %f, y %f, translation: x %f, y %f", location.x, location.y, translation.x, translation.y);
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didEndSwipingView:(UIView *)view atLocation:(CGPoint)location {
    NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
}

To swipe the top view programmatically:

[self.swipeableView swipeTopViewToLeft];
[self.swipeableView swipeTopViewToRight];

To discard all views and reload programmatically:

[self.swipeableView discardAllSwipeableViews];
[self.swipeableView loadNextSwipeableViewsIfNeeded];

Requirements

  • iOS 7 or higher.
  • Automatic Reference Counting (ARC).

Credits

  • Thanks iamphill for adding new delegates.
  • Thanks mdznr for making the code style consistent.
  • Thanks coryalder for making dataSource and delegate IBOutlets.

License

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

zlswipeableview's People

Contributors

zhxnlai avatar mdznr avatar coryalder avatar gitter-badger avatar

Watchers

James Cloos avatar Blue Sky 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.