Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Animations on the root layer of a view are disabled by default. Try applying a transform to the view instead, e.g. [view setTransform:CGTransform3D...]. If you must do it at the layer level, add a layer to the root layer and perform your transforms on it instead. Also the view animation block [UIView beginAnimations...] only has an effect when animating view properties--as opposed to layer properties.</p> <p><strong>Update:</strong></p> <p>So here is what your code would look like with explicit animation (CATransaction is not required)</p> <pre><code>CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"]; CATransform3D rotateTransform = CATransform3DMakeRotation(0.3, 0, 0, 1); CATransform3D scaleTransform = CATransform3DMakeScale(0.10, 0.10, 0.10); CATransform3D positionTransform = CATransform3DMakeTranslation(24, 423, 0); CATransform3D combinedTransform = CATransform3DConcat(rotateTransform, scaleTransform); combinedTransform = CATransform3DConcat(combinedTransform, positionTransform); [anim setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; [anim setToValue:[NSValue valueWithCATransform3D:combinedTransform]]; [anim setDuration:1.0f]; [layerToAnimate addAnimation:anim forKey:nil]; </code></pre> <p>Keep in mind that this only performs the animation. You actually have to set the transform property of the layer with a call to:</p> <pre><code>[layerToAnimate setTransform:combinedTransform]; </code></pre> <p>as well. Otherwise it will just snap back to its starting position.</p> <p>Layer properties are animated implicitly whenever you set them <em>except</em> in the case where you are animating the root layer of a view. In that case animations are turned off by default and I've found that what I always have to do instead is animate the view rather than the layer when I am interested in animating the root. So what this means is that a call to any layer within your layer tree that makes a property change will be animated implicitly. For example:</p> <pre><code>CALayer *root = [view layer]; CALayer *sublayer = [[root sublayers] objectAtIndex:0]; [sublayer setTransform:combinedTransform]; </code></pre> <p>This is the only way I know (knew) you can actually use implicit animation on a layer. However, what your code has pointed out is that you can turn the layer animation on for the root layer simply by placing the changes to the <strong>layer</strong> within a UIView animation block. That's pretty interesting and handy. This is quite a helpful discovery. </p> <p>Maybe this is buried in the docs somewhere, but I have yet to come across it.</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.
    3. 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