Note that there are some explanatory texts on larger screens.

plurals
  1. PO3D Door Open Animation between two UIViewControllers
    primarykey
    data
    text
    <p>This has been asked before, but there is no sample code to be found on stackoverflow and no proper solutions as far as I'm aware. I have a solution, but it looks crap. I'd be grateful for any input and modifications to get a more realistic 3D door open / book cover animation.</p> <p>Aim is to have an animation between UIViewControllers so that you get the effect as if you were opening a door or a book cover. ViewController 2 is static and in the background. Above it you place ViewController 1 which covers ViewController 2. The animation will open ViewController 1 (like a hardcover book) and reveal ViewController 2 (your first page so to say, or whatever is behind the door).</p> <p>First thing to note is that you can't do this with an UINavigationController as it is difficult to overwrite the custom animations. A proper tutorial on how to set up our two ViewControllers can be found here: <a href="http://dmunsie.wordpress.com/2009/08/07/custom-animations-between-uiviewcontrollers/" rel="nofollow noreferrer">ViewController Animations</a></p> <p>So once everything is setup, here is my custom animation which looks crap. It basically looks as if you are squeezing the door / cover of the book to the left. There is no 3D feel to it, I'm afraid. Any suggestions of how to make this better would be welcome:</p> <pre><code>-(void)openDoorTo:(UIViewController *)aController duration:(float)aDuration { [aController viewWillAppear:YES]; [activeController viewWillDisappear:YES]; [self.view insertSubview:aController.view belowSubview:activeController.view]; // so that it is below activeController [aController viewDidAppear:YES]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:aDuration]; aController.view.transform = CGAffineTransformMakeTranslation(0,0); CATransform3D _3Dt = CATransform3DIdentity; _3Dt = CATransform3DTranslate(_3Dt, -320, 0, 0); _3Dt = CATransform3DRotate(_3Dt, M_PI * 1.5, 0.0, 1, 0.0); _3Dt = CATransform3DTranslate(_3Dt, 320, 0, 0); activeController.view.layer.transform = _3Dt; [UIView commitAnimations]; [self performSelector:@selector(animationDone:) withObject:aController afterDelay:aDuration]; } </code></pre> <p>I think the main problem is that I don't really know how to handle <code>CATransform3DTranslate</code> and <code>CATransform3DRotate</code>.</p> <p>Here are some posts on this, but I can't really see how to apply them to a 3D Door opener:</p> <p><a href="https://stackoverflow.com/questions/6531332/how-to-rotate-an-uiimageview-with-catransform3drotate-make-an-effect-like-door-op">3D Door - but Axis in the middle</a></p> <p><a href="https://stackoverflow.com/questions/5385898/the-paper-folding-unfolding-effect-in-twitter-for-ipad/6502349#6502349">3D Unfolding</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload