I'm building a flashcard-like app, and I'm using a library KolodaView: https://github.com/Yalantis/Koloda
I have this extension which returns a UIView
as the front of a flashcard:
extension StudyViewController: KolodaViewDataSource {
func kolodaNumberOfCards(koloda:KolodaView) -> UInt {
return UInt(memories.count)
}
func koloda(koloda: KolodaView, viewForCardAtIndex index: UInt) -> UIView {
return UIImageView(image: memories[Int(index)].frontImage)
}
func koloda(koloda: KolodaView, viewForCardOverlayAtIndex index: UInt) -> OverlayView? {
return NSBundle.mainBundle().loadNibNamed("OverlayView",owner: self, options: nil)[0] as? OverlayView
}
}
And I want to be able to transform the from view to the back view with a tap:
func koloda(koloda: KolodaView, didSelectCardAtIndex index: UInt) {
let frontView: UIView = koloda as KolodaView
let backView: UIView = UIImageView(image: memories[Int(index)].backImage)
if showingFront == true {
UIView.transitionFromView(frontView, toView: backView, duration: 1, options: UIViewAnimationOptions.TransitionCrossDissolve, completion: nil)
} else {
UIView.transitionFromView(backView, toView: frontView, duration: 1, options: UIViewAnimationOptions.TransitionCrossDissolve, completion: nil)
showingFront = false
}
}
The transition was successful but after it finishes, the flashcard will turn from a KolodaView
to a giant UIView
How do I transform a KolodaView
to anther KolodaView
?