0

I have two views that flip (like Turing over a card horizontally). iOS 13 has depreciated the begin animations code and I'm trying to figure out how to use [UIView animateWithDuration:delay:options:animations:completion:]

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.ABCard cache:YES];

[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];

I'm trying to do the following but the animation just switches views instantly with no flip action.

 [UIView animateWithDuration:1.0 delay:1.0
                        options: UIViewAnimationCurveEaseInOut | UIViewAnimationTransitionFlipFromLeft
                     animations:^{
        [self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
                           } completion:^(BOOL finished){
                           }];
MB.
  • 723
  • 1
  • 11
  • 28

1 Answers1

0

exchangeSubviewAtIndex doesn't change the look of the animation so it's won't result in an animation, which is why you just see it flip.

Results from this answer may help you with a proper solution: iPhone Flip Animation using UIViewAnimationTransitionFlipFromLeft in landscape mode

Durstann
  • 122
  • 11