Skip to content

umbrellaitcom/DeckView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UMDeckView

UMDeckView is an easy-to-use Swift library that provides a deck of views that can be swiped any side (inspired by the Tinder app).

Version License Platform

Requirements

  • iOS 10.0+
  • Xcode 10.1

Installation

Manually

Clone this repo and manually add the source files to project.

CocoaPods

If you are using CocoaPods just add in your podfile:

pod 'UMDeckView'

Usage

  1. Create a new view (from storyboard or programmatically) inheriting DeckView and add it on your view. Conform to DeckViewDataSource as you would with a UITableView, register nib containing subclass of CardView and set the view's data source.
class ViewController: UIViewController, DeckViewDataSource {

    @IBOutlet weak var deckView: DeckView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Register nib containing subclass of CardView
        let nib = UINib(nibName: "MyCardView", bundle: nil)
        deckView.register(nib, forCardReuseIdentifier: "MyCardView")


        // Set the deckView's delegate & data source.
        deckView.delegate = self
        deckView.dataSource = self
    }
}
  1. Return the number of cards that you wish to add in the deck, as you would do with UITableViewDataSource.
func numberOfItems(in deckView: DeckView) -> Int {
    return 3
}
  1. Create your cards as you would do with UITableViewCell. Your cards must inherit CardView.
func deckView(_ deckView: DeckView, cardForCellAt index: Int) -> CardView {
    let card = deckView.dequeueReusableCard(withIdentifier: "MyCardView")
    card.backgroundColor = UIColor.random()
    return card
}

Features

For a detailed guide on how to use the features visit here

  1. Throw a card any side

  2. Infinite loop of cards

Author

UmbrellaIT, alexey.pak@umbrellait.com

License

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