I'm trying to create an IOS app and flip two views when pressing some buttons. I have found the flip animation but I want the flip to change the content to the new view when it is flipped 90° and not when the animation is completed. This is my function:
func animationFlip(fromView:UIView, toView:UIView, animationTime:Float)
{
UIView.animateWithDuration(NSTimeInterval(animationTime), animations: {
UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: fromView, cache: true)
},completion:{completion in
UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -> Void in
fromView.hidden = true;
toView.hidden = false;
UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: toView, cache: true)
})
})
}
I have found this code which seems to do the trick but it is written in obj-c. How can it be translated to swift?
[UIView transitionFromView:viewToReplace
toView:replacementView
duration:1
options:UIViewAnimationOptionTransitionFlipFromBottom
completion:nil];
Thanks in advance!