iOS开源:CardSlider - 基于卡片的 Tinder 风格动画效果及演示

CiaFerris 7年前
   <h2>Card Slider for Swift</h2>    <p>Tons of apps use a Tinder-style interface with cards that users can swipe right to 'like' or left to 'dislike'. But Yaroslav Zubko came up with an innovative and fresh approach to giving users more options besides just 'like' or 'dislike'. Here's Yaroslav's Dribbble shot that inspired me to create a 100% Swift project of this unique & new interface:</p>    <p><img src="https://simg.open-open.com/show/ff886d6ef580157abfebb71b36a6e264.gif"></p>    <p>And here's a demo of the actual Swift project:</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/53046709fde13fdf06ee557c1f45c341.gif"></p>    <p>Note: you can pivot the cards in any direction, it all depends on where your finger is on the card.</p>    <h2>Usage</h2>    <p>This project isn't a framework, it's more so of a demonstration of how to approach this sort of user interface. Card Slider basically uses a UIPanGestureRecognizer in conjunction with several UIKit Dynamics behaviors. Because of this, ideally you would want all the card logic code in a view controller class, so I opted not make an external class that uses delegation to talk to the view controller.</p>    <h3>CardView.swift</h3>    <p>Most of the logic code is in the ViewController class, but each card is a subview of CardView . In the demo project, ImageCard is a subview of CardView and has its own custom subviews and layouts. You can create your own subclass of CardView and modify the cards data structure in ViewController to swap in your own custom cards. You can also modify the CardOption enum to show your own custom text on the cards for each of the 6 options (you may even add more, but that would require dealing with more emojis and laying them out properly.)</p>    <h3>EmojiOptionsOverlay.swift</h3>    <p>This file has all the logic code associated with showing the 6 emojis on the sides when the user pans the card around, as well as the heart emoji on the top right.</p>    <h2>Credits</h2>    <p>Yaroslav Zubko, the creator of the Dribbble shot that inspired this project, was kind enough to send me his design files. This concept and any artwork (including the emojis) is thanks to Yaroslav. https://dribbble.com/Yar_Z</p>    <p> </p>    <p> </p>    <p> </p>