6

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

Andrei
  • 1,183
  • 2
  • 19
  • 40

1 Answers1

9

Try this:

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

That should work. Hope that Helps!

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
msgambel
  • 7,320
  • 4
  • 46
  • 62
  • 1
    It works, awesome! Thanks!. One small change in your code I had to make, was change holderView to flipsideView (that is the view when the card is flipped) – Andrei Apr 02 '12 at 23:13