Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just managed to get sth. like this to work using CoreAnimation / QuartzCore Framework... be sure to</p> <pre><code>#import &lt;QuartzCore/QuartzCore.h&gt; </code></pre> <p>when you want to animate, use CATransform3Dand the poorly documented CATransform3D.m34 property. this will do the <strong>first half</strong> of the animation (assuming 200x200&lt;->450x450 with 180° rotation):</p> <pre><code>[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; [UIView setAnimationDelegate:self]; CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 / -1000; // this turns on perspective! rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 90.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f); someView.layer.transform = rotationAndPerspectiveTransform; someView.bounds = CGRectMake(0, 0, 325, 325); [UIView commitAnimations]; </code></pre> <p>for the <strong>second half</strong> of the animation, you have to add/remove your view to the hierarchy. this example shows hiding/showing of a view that already exists as a subview of <code>someView</code>, it also makes use of a <code>BOOL isUp</code> instance variable (the first half of the aniation is independent of the isUp-flag!)</p> <pre><code>- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { if (flag) { if (isUp) { someSubView.hidden = YES; // hide subview [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; CATransform3D rotationAndPerspectiveTransform = CATransform3DRotate(someView.layer.transform, -90.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f); someView.layer.transform = rotationAndPerspectiveTransform; someView.bounds = CGRectMake(0, 0, 200, 200); [UIView commitAnimations]; isUp = NO; } else { someSubView.hidden = NO; // Show subview [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; CATransform3D rotationAndPerspectiveTransform = CATransform3DRotate(someView.layer.transform, 90.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f); someView.layer.transform = rotationAndPerspectiveTransform; someView.bounds = CGRectMake(0, 0, 450, 450); [UIView commitAnimations]; isUp = YES; } } } </code></pre> <p>one last thing: everything in your view will appear mirrored, it might not be the ideal solution, but mirroring back by applying a <code>CGAffineTransform</code> to the subview does the trick:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; someSubView.transform = CGAffineTransformMakeScale(-1, 1); isUp = NO; } </code></pre> <p>i'm alredy a month late with this solution but i hope it helped someone :)</p> <p>i first tried using the animateWithDuration:animations:completion: block-based API but that turned out to lag heavily (no smooth first/second-half animaiton even without touching subviews).</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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