CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jul 2016 |
| SPMSupports SPM | ✗ |
Maintained by George Kye, George Kye.
| Depends on: | |
| Stellar | >= 0 |
| PeekView | >= 0 |
UIView sublass for creating Tinder like swipe cards, with a peek view.
Swiper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Swiper'Check out the demo app for a detailed example.
A Swiper view can be added via storyboard or programmatically
var swiperView = Swiper(frame: CGRect(x: 0, y: 0, width: 350, height: 350)))
view.addSubview(swiperView)
swipeView.delegate = self
swipeView.dataSource = selfReturns the images to be displayed within the Swiper view.
public func cardData() -> [SwiperData]Returns the number of items to be displayed by the Swiper view.
public func numberOfCards()->IntMethod is called when the Swiper view is first display and each time a swipe actions occurs. Returns the current index of the card and its dataSource
public func didShowCardAtIndex(index: Int, dataSource: SwiperData)Method is called when the Swiper view is swipped left or programtically undoSwipe. Returns the current index of the card and its dataSource
public func didUndoAction(index: Int, dataSource: SwiperData)Method is called when the Swiper view is tapped. Returns the current index of the card of the current item
public func didSelectCardAtIndex(index: Int)Method is called when the Swiper view is no more items to be displayed from its current dataSource
public func cardsDidRunOut(status: Bool)Swiper supports both right and left swipe actions. Swiper Right to move to the next card and Swipe left to undo an action. These actions are also supported programtically.
public func swipeToNext()
public func undoSwipe()Reloads the Swiper views items from its current dataSource and refreshes display.
public func reloadData()Must the peekViewEnabed = true and conform to the peekViewDelegate in order to use the PeekView
swipeView.peekViewEnabled = true
swipeView.peekViewDelegate = selfIn order for the peekView to function a parentViewController and contentViewController must be set (actions are optional). Below is an example.
func swiperPeekViewAttributes() -> SwiperPeekViewAttributes {
let controller = storyboard?.instantiateViewControllerWithIdentifier("PeekViewController") as! PeekViewController
controller.image = imgs[currentIndex].image
controller.labelText = imgs[currentIndex].title
let actions = [
PeekViewAction(title: "Like", style: .Selected),
PeekViewAction(title: "Show Details", style: .Default),
PeekViewAction(title: "Cancel", style: .Destructive) ]
let attributes = SwiperPeekViewAttributes.init(parentVC: self, contentVC: controller, actions: actions)
return attributes
}Returns the selected index of selected action from the PeekView
func swiperPeekViewDidSelectAtionAtIndex(index: Int)Swiper is available under the MIT license. See the LICENSE file for more info.