iPhone Curl Left and Curl Right transitions iPhone Curl Left and Curl Right transitions curl curl

iPhone Curl Left and Curl Right transitions


It's possible to do curls in any of the four directions by using a container view. Set the container view's transformation to the angle you want and then do the curl by adding your view to the container view, not your app's main view which does not have a transformed frame:

NSView* parent = viewController.view; // the main viewNSView* containerView = [[[UIView alloc] initWithFrame:parent.bounds] autorelease];containerView.transform = CGAffineTransformMakeRotation(<your angle here, should probably be M_PI_2 * some integer>);[parent addSubview:containerView]; [UIView beginAnimations:nil context:nil];[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:YES];[containerView addSubview:view];[UIView commitAnimations];


I actually managed to achieve this effect by changing the orientation of my UIViewController. The strange thing is, I had my controller nesten in another one when it wasn't working, but when I set him as the immediate view controller, it worked.

Code that does it:

In a UIViewController that is the main view controller in my app delegate and only allows landscape orientation (as you see in the 2nd method below) I have the following:

-(void)goToPage:(int)page flipUp:(BOOL)flipUp {     //do stuff...     // start the animated transition     [UIView beginAnimations:@"page transition" context:nil];     [UIView setAnimationDuration:1.0];     [UIView setAnimationTransition:flipUp ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown forView:self.view cache:YES];     //insert your new subview     //[self.view insertSubview:currentPage.view atIndex:self.view.subviews.count];      // commit the transition animation      [UIView commitAnimations];}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);}


I also struggled with this. To get the curl to come from the right or left you can create an intermediate view and transform it. So, let's say the view you're transitioning (myView) is a child of the main window (parentView):

-parentView-->myView

You will insert an intermediate view in between (easily done in Interface Builder):

-parentView-->containerView--->myView

Then, use the following code to flip the container 90 deg left and the transitioned view 90 deg right:

containerView.transform = CGAffineTransformMakeRotation(-M_PI_2);myView.transform = CGAffineTransformMakeRotation(M_PI_2);

myView will still appear upright to the user but the transition will think it's applied at 90 degrees from the left.

Note that depending on how auto-scaling your views are, you might have to fix the frame sizes after applying the transform, eg

  containerView.frame = CGRectMake(0.0, 0.0, 768.0, 1024.0);  myWebView.frame = CGRectMake(0.0, 0.0, 768.0, 1024.0);

Hope this helps. The is the closest you can get to UIViewAnimationTransitionCurlLeft and UIViewAnimationTransitionCurlRight.