Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhxnlai/ZLSwipeableView
A simple view for building card like interface inspired by Tinder and Potluck.
https://github.com/zhxnlai/ZLSwipeableView
Last synced: 3 months ago
JSON representation
A simple view for building card like interface inspired by Tinder and Potluck.
- Host: GitHub
- URL: https://github.com/zhxnlai/ZLSwipeableView
- Owner: zhxnlai
- License: mit
- Created: 2014-11-02T01:46:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-13T01:22:22.000Z (over 8 years ago)
- Last Synced: 2024-10-29T17:43:18.447Z (4 months ago)
- Language: Objective-C
- Homepage:
- Size: 5.73 MB
- Stars: 2,824
- Watchers: 73
- Forks: 330
- Open Issues: 59
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios-animation - ZLSwipeableView
README
ZLSwipeableView
===============
[](https://travis-ci.org/zhxnlai/ZLSwipeableView)
[](https://gitter.im/zhxnlai/ZLSwipeableView?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)A simple view for building card like interface like [Tinder](http://www.gotinder.com/) and [Potluck](https://www.potluck.it/). ZLSwipeableView was originally developed for [Murmur](http://zhxnlai.github.io/#/murmur).
**Notice:** The Objective-C version of ZLSwipeableView is no longer actively maintained.
### Please checkout the swift version: https://github.com/zhxnlai/ZLSwipeableViewSwiftPreview
---
###Swipe

###Swipe Cancel

###Swipe Programmatically

###Swipe Programmatically II
CocoaPods
---
You can install `ZLSwipeableView` through CocoaPods adding the following to your Podfile:pod 'ZLSwipeableView'
Usage
---
Check out the [demo app](https://github.com/zhxnlai/ZLSwipeableView/archive/master.zip) for an example.`ZLSwipeableView` can be added to storyboard or instantiated programmatically:
~~~objective-c
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.
~~~objective-c
// required data source
self.swipeableView.dataSource = self;#pragma mark - ZLSwipeableViewDataSource
- (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
return [[UIView alloc] init];
}
~~~
The demo app includes examples of both creating views programmatically and loading views from Xib files that [use Auto Layout](https://github.com/zhxnlai/ZLSwipeableView/issues/9).A `ZLSwipeableView` can have an optional delegate to receive callback.
~~~objective-c
// optional delegate
self.swipeableView.delegate = self;#pragma mark - ZLSwipeableViewDelegate
- (void)swipeableView:(ZLSwipeableView *)swipeableView
didSwipeView:(UIView *)view
inDirection:(ZLSwipeableViewDirection)direction {
NSLog(@"did swipe in direction: %zd", direction);
}
- (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:
~~~objective-c
[self.swipeableView swipeTopViewToLeft];
[self.swipeableView swipeTopViewToRight];
...
~~~To discard all views and reload programmatically:
~~~objective-c
[self.swipeableView discardAllViews];
[self.swipeableView loadViewsIfNeeded];
~~~Requirements
---
- iOS 7 or higher.
- Automatic Reference Counting (ARC).Credits
---
- Thanks [iamphill](https://github.com/iamphill) for adding new delegates.
- Thanks [mdznr](https://github.com/mdznr) for making the code style consistent.
- Thanks [coryalder](https://github.com/coryalder) for making dataSource and delegate IBOutlets.License
---
ZLSwipeableView is available under MIT license. See the LICENSE file for more info.