Building an app containing flashCards. They surely require the ability to flip a card. To do this i have a UIViewController and to avoid flipping the whole view I've implemented my subView into a container.
I have declared two subviews in the container named, frontView
and backView
. frontView
got red background and label saying front while backView
got a blue background and label saying back.
I have declared a variable so i can check which side is showened : var showingFront = true
Got a UIButton action which calls the following func:
if showingFront == true {
UIView.transitionFromView(forside, toView: bagside, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight, completion: nil)
showingFront = false
} else {
UIView.transitionFromView(bagside, toView: forside, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight, completion: nil)
showingFront = true
}
This flips the view back and forth but the backgroundColor disappears with the labels and i can only see the container flipping?. All help is appreciated
try this way: in the storyboard create a UIView(width = 90, height = 132) and change it class to " FlashCard"
also create a button to flip the flashcard.
FlashCard:
in your viewcontroller: