J'ai un CAShapeLayer où j'anime un cercle. L'animation consiste d'abord à "dessiner" le cercle dans le sens des aiguilles d'une montre puis à redessiner le cercle dans le sens des aiguilles d'une montre. Sort d'un "cercle tournant". Une autre façon de le mettre: Déplacez le point de fin de course du chemin pour commencer, puis déplacez le point de départ jusqu'à la fin.Glitches lors de la mise en file d'attente CAAnimations
L'animation elle-même fonctionne, mais elle produit des problèmes de temps en temps. Il se manifeste par un bref aperçu du cercle entier lorsqu'il est supposé être "non tiré".
Pourquoi cela se produit-il et comment pouvez-vous le réparer?
Merci,
// Shape creation
layer.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, self.width - 2 * OUTER_BORDER_WIDTH, self.width - 2* OUTER_BORDER_WIDTH)].CGPath;
// Animation queuing
-(void) applyNextAnimation
{
CABasicAnimation* animation;
if (self.animatingOpening)
{
animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
self.animatingOpening = NO;
}
else
{
animation = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
self.animatingOpening = YES;
}
animation.duration = 1.0f;
animation.autoreverses = NO;
animation.delegate = self;
animation.removedOnCompletion = YES;
[self.outerCircleLayer addAnimation:animation forKey:@"stroke"];
}
// Animation stop callback
-(void) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if (self.isAnimating)
{
[self applyNextAnimation];
}
}
Excellent! J'ai ajouté '[CATransaction setDisableActions: NO];' à la fin de l'instruction if-else pour conserver une animation non montrée ici. (Une autre couche) –
Heureux que c'était utile. Je vois que vous avez affaire à des problèmes intéressants impliquant le stockage de données de capteurs à haute fréquence, donc j'ai ajouté quelques réflexions à l'une de vos autres questions .. – foundry