Search code examples
iosios6core-animationautolayoutnslayoutconstraint

How to animate a NSLayoutConstraint within a CAAnimationGroup


I had for example this in pre-autolayout times which was added to a CAAnimationGroup.

CABasicAnimation *resizeAnimation = [CABasicAnimation animationWithKeyPath:@"bounds.size"];
[resizeAnimation setToValue:[NSValue valueWithCGSize:CGSizeMake(10.0f, 10.0f)]];
resizeAnimation.fillMode = kCAFillModeForwards;
resizeAnimation.removedOnCompletion = NO;

Under autolayout I assume that now I will need to change the Constant property of my Constraints on the object.

So could you please help me to understand how to prepare the animation of a constraint.

EDIT In Best Practices Mastering Auto Layout - at around 30m he does this on OSX with NSAnimationContext - he does not talk about iOS.


Solution

  • Best answer I can come up with is you cannot do this. You either need to animate a layer or use the UiView animation methods.