J'essaye d'animer une sous-couche sur un calque racine qui est attaché à un UIView dans l'objectif C ios. J'ai essayé le nombre de réponses disponibles ici mais la sous-couche est fixe et ne change pas sa position du tout.Animation CALayer pour passer d'un point à un autre
J'ai essayé la méthode suivante pour l'animer:
-(void)moveLayer:(CALayer*)layer to:(CGPoint)point with:(CGRect)bounds
{
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath,NULL,74.0,74.0);
CAKeyframeAnimation * theAnimation;
// Create the animation object, specifying the position property as the key path.
theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
theAnimation.path=thePath;
theAnimation.duration=5.0;
// Add the animation to the layer.
[layer addAnimation:theAnimation forKey:@"position"];
}
Et aussi en utilisant
`
[featureLayer setFrame:oldRect];
CGRect oldBounds = oldRect;
CGRect newBounds = faceRect;
CABasicAnimation* revealAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"];
revealAnimation.fromValue = [NSValue valueWithCGRect:oldBounds];
revealAnimation.toValue = [NSValue valueWithCGRect:newBounds];
revealAnimation.duration = 3.0;
// Update the bounds so the layer doesn't snap back when the animation completes.
featureLayer.bounds = newBounds;
[featureLayer addAnimation:revealAnimation forKey:@"revealAnimation"];
[self.previewLayer setMask:featureLayer];
`
Si quelqu'un peut me aider ce sera génial. Merci d'avance.
Modifier 1
Juste pour être sûr que ce soit une image de masque sur la couche racine, je veux animer le masque pour se déplacer d'une position à l'autre, mais il est encore rester.