Start a Project

Tinder-like card swipe in Swift.

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:

https://mobikul.com/wp-content/uploads/2022/06/Screen-Recording-2022-06-29-at-12.47.37-PM.mov

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

Exit mobile version