1

What I'd like to do is somewhat similar to this SO question which reference this MLB app, except instead of a grid, I use SwipeView which is based on UIScrollView.

The answers to that question isn't satisfactory. Seems like you shouldn't need to write the entire animation sequence manually.

Is there a way to do this by simply using presentViewController and the built-in flip transition effect?

Community
  • 1
  • 1
pixelfreak
  • 17,714
  • 12
  • 90
  • 109

3 Answers3

8

Swift iOS 8

If you would like to Flip View controller by View controller

    // Create a new view controller and pass suitable data.
    let storyboard = UIStoryboard(name: "Main", bundle: nil);

    // assign page view content loader
    let fBSignRegisterViewController = storyboard.instantiateViewControllerWithIdentifier("FBSignRegisterViewController")
        as? FBSignRegisterViewController;

    fBSignRegisterViewController?.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal

     self.presentViewController(fBSignRegisterViewController!, animated: true, completion: nil)
Vinod Joshi
  • 7,696
  • 1
  • 50
  • 51
2

You are correct, there's a built in method on UIView to handle this:

[UIView transitionWithView:containerView
                  duration:0.2
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{ 
                    [fromView removeFromSuperview]; 
                    [containerView addSubview:toView]; }
                completion:NULL];

Or alternatively, with viewControllers:

AboutViewController * vc = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:vc animated:YES];
Alfie Hanssen
  • 16,964
  • 12
  • 68
  • 74
  • I did try this. It does the flipping but it doesn't do the growing. How do we accomplish that? – pixelfreak Jul 26 '13 at 21:47
  • For growing you'll have to explore Transforms. Create a custom one and set it as the transform on your view/viewController. If transforms are what you end up using, you wouldn't use them in conjunction with the above default transitions, you'd essentially be rolling your own. Animating [view setTransform:myFlipTransform] – Alfie Hanssen Jul 26 '13 at 21:49
0

I think what you are looking for is a method for UIView called transitionwithView. Check out an example here.

JonahGabriel
  • 3,066
  • 2
  • 18
  • 28