Tinder-like card swipe in Swift.

Updated 21 December 2023

Save

We have all seen views in dating apps where we can just swipe left or right to accept or reject something. If you are bored with table views and collection views, you can use Swipe cards. The whole card-swiping idea is now used in tons of apps. Let’s check how can we implement card swipe in Swift.

Now, we are implementing Swipe cards in Swift and it’s pretty easy to implement in Swift. I have used a third-party library named Shuffle but it can be implemented without using any library. I have used the Shuffle library to implement it easily.

1. Create a new project & add a Shuffle pod in your pod file.

2. Now install the pod & import it into your view controller.

3. Create a view named swipeView in the storyboard.

4. Now create a card function taking an image as a parameter & returning SwipeCard.

Create left & right overlays and set them on card overlays. The card returned from card(fromImage:) displays an image, can be swiped left or right, and has overlay views for both directions.

5. Add multiple images in the asset & create an array of card images.

6. Initialize your card data and place a SwipeCardStack on your view in viewDidLoad.

7. Conform your class to SwipeCardStackDataSource and set your card stack’s dataSource.

Full code:

Output:

Conclusion:

This is how we swipe cards in Swift. You can use more of its properties.

Thanks for reading this article.

If I got something wrong, let me know in the comments. I would love to improve.

For more interesting blogs check out here – https://mobikul.com/blog/

Reference link: https://swiftobc.com/repo/mac-gallagher-Shuffle-swift-cards

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home