Reputation: 183
In this tutorial I have found how to make an animation CALayer in video: http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos
CABasicAnimation *animation
=[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration=3.0;
animation.repeatCount=5;
animation.autoreverses=YES;
// animate from fully visible to invisible
animation.fromValue=[NSNumber numberWithFloat:1.0];
animation.toValue=[NSNumber numberWithFloat:0.0];
animation.beginTime = AVCoreAnimationBeginTimeAtZero;
[overlayLayer1 addAnimation:animation forKey:@"animateOpacity"];
But it does not work when I want to animate the movement of CALayer:
animation.keyPath = @"position.x";
or
animation.keyPath = @"position.y";
Is it possible to animate the movement of the CALayer?
Upvotes: 1
Views: 1377
Reputation: 183
Any animations will be interpreted on the video's timeline, not real-time, so you should:
Set animations’ beginTime property to AVCoreAnimationBeginTimeAtZero rather than 0 (which CoreAnimation replaces with CACurrentMediaTime);
Set removedOnCompletion to NO on animations so they are not automatically removed;
Upvotes: 2
Reputation: 1122
Try using this keypath :
animation.keyPath = @"transform.translation.x";
Upvotes: 0