Hello everyone. I’m an iOS Developer. This is my first article for Medium. I searched for Koloda View on the internet but I couldn’t find enough resources. That’s why, I decided to write this article. Good codings :).
Let’s create the project first.
We have to install the pod in the project directory. (You can write these codes to terminal.)
cd /Users/yourname/Desktop/testKolodapod initpod install
We have a podfile. Let’s open this file, add necessary codes and run ‘pod install’ code from terminal.
pod “Koloda” // add in podfilepod install // run in terminal
Let’s open testKoloda.xcworkspace file, add Navigation Controller in ViewController, add a View in ViewController and classify this View as KolodaView. (The module for this View should be ‘Koloda’.)
We need to define the objects in the ViewController.
OK, everything is perfect for now. Here we go. I added three images to project, you can add as many as you want.
We should append these images to the imageStock array.
We need to init kolodaView. Let’s create a function for kolodaView and call the this function in viewDidLoad.
Let’s add extension so we can customize kolodaView.
Now, the XCode will be angry to us “Add the functions I want!”. You don’t need to be angry, I’m adding.
OK :D, I added some codes before i show you. Let’s take a look at what these codes do.
viewForCardAt -> Return a view to be displayed at the specified index in the KolodaView.
kolodaSpeedThatCardShouldDrag -> Allow management of the swipe animation duration
kolodaNumberOfCards -> Return the number of items (views) in the KolodaView.
Oh. I forgot something very important. We should reload kolodaView after images are ready. Add this function to your class.
It seems perfect. But we can add a function.
This method is called when the KolodaView has no cards to display.
Now try it.
Thank you for reading.
Source Code: https://github.com/cemkazim/testKoloda.git