CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

WDFlashCard 1.0.6

WDFlashCard 1.0.6

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 3.1
SPMSupports SPM

Maintained by Vladimir Dinic.



  • By
  • Vladimir Dinic

WDFlashCard is a simple lightweight component for displaying flashcards inside iOS apps. Just add front and back view, set flashcard animation type and duration.

GitHub Logo

Installation:

Manual:

Just download source code and include WDFlashCard/WDFlashCard/WDFlashCardView.swift in your project.

Usage

Add UIView to storyboard or Xib file and set WDFlashCard as its class. Also, add two views inside this WDFlashCard view to use them as a back and front view for flash card view. Then set WDFlashCardDelegate (using interface builder or in code) and implement its metods: flipBackView to set back view and flipFrontView to set front view.

class ViewController: UIViewController, WDFlashCardDelegate {
    
    @IBOutlet weak var backView: UIView!
    @IBOutlet weak var frontView: UIView!
    @IBOutlet weak var flashCard: WDFlashCard!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        flashCard.duration = 2.0
        flashCard.flipAnimation = .flipFromLeft
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //MARK: WDFlashCardDelegate methods
    
    func flipBackView(forFlashCard flashCardView: WDFlashCard) -> UIView {
        return backView
    }
    
    func flipFrontView(forFlashCard flashCardView: WDFlashCard) -> UIView {
        return frontView
    }
}

If you want to disable tap to flip option, you can set flashCard.disableTouchToFlipFesture to true (By default, it is set to true).

flashCard.disableTouchToFlipFesture = true

In that case, you are still able to flip this view. All you need to do is to call flip() method from wherever you need:

flashCard.flip()

For better understanding look at the source code example.

Note:

If you find any bug, please report it, and I will try to fix it ASAP.