How To Add Card Swipe Animation Feature To A Project In iOS?

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” // pod install // 

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.

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.

💻 iOS Developer 🎸 Rock Musician

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store