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).
- iOS 10.0+
- Xcode 10.1
Clone this repo and manually add the source files to project.
If you are using CocoaPods just add in your podfile:
pod 'UMDeckView'
- Create a new view (from storyboard or programmatically) inheriting
DeckView
and add it on your view. Conform toDeckViewDataSource
as you would with aUITableView
, 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
}
}
- 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
}
- Create your cards as you would do with
UITableViewCell
. Your cards must inheritCardView
.
func deckView(_ deckView: DeckView, cardForCellAt index: Int) -> CardView {
let card = deckView.dequeueReusableCard(withIdentifier: "MyCardView")
card.backgroundColor = UIColor.random()
return card
}
For a detailed guide on how to use the features visit here
-
Throw a card any side
-
Infinite loop of cards
UmbrellaIT, alexey.pak@umbrellait.com
UMDeckView is available under the MIT license. See the LICENSE file for more info.