I wrote a function to flip. During the animation, I want to hide one view and show another.
This does not work. But if I try to move this view after the transition is complete, it will show me my desired result.
Below is the code I wrote.
func tapped() {
if (showingBack) {
UIView.transitionWithView(self.contentView!, duration: 1, options: .TransitionFlipFromRight, animations: {
self.contentView?.viewWithTag(1)?.hidden = false
self.contentView?.viewWithTag(2)?.hidden = true
}, completion: { complete in
})
} else {
UIView.transitionWithView(self.contentView!, duration: 1, options: .TransitionFlipFromRight, animations: {
self.contentView?.viewWithTag(1)?.hidden = true
self.contentView?.viewWithTag(2)?.hidden = false
}, completion: { complete in
})
}
showingBack = !showingBack
}
source
share