iPhone card like flipping animation

2020-06-18 01:45发布

问题:

I'm trying to create a card flipping animation on iOS, and I'm failing miserably.
Basically I have a global View with a Controller. Inside I have a holderView, which contains the card.
I have the front of the card, which is the mainView, and then the back of the card, which is a flipSideView.

I have tried doing something like this:

[UIView animateWithDuration:1.0
                              delay:0
                            options:UIModalTransitionStyleFlipHorizontal
                         animations:^{
        NSLog(@"started");

        [mainView removeFromSuperview];
        [holderView addSubview:flipsideView];


    } completion:^(BOOL finished){

        NSLog(@"completed");
    }];

That doesn't work, does weird things, I have tried a lot of different things but cannot get it to work perfectly. Would anyone have an idea how I can do that ?

Thank you

回答1:

Try this:

[UIView transitionFromView:mainView
  toView:holderView
  duration:1.0f
  options:UIViewAnimationOptionTransitionFlipFromRight
  completion:^(BOOL finished) {}];

That should work. Hope that Helps!