2010-05-14 23 views
0

J'utilise CAKeyFrameAnimation pour faire une rotation d'une image en forme de flèche.Pourquoi CAAnimation Rotation retourne à l'état précédent

Le problème est que l'imageview revient à l'état antérieur après l'animation.

code:

CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation]; rotation.duration = 0.55; rotation.cumulative = TRUE; rotation.removedOnCompletion = NO; if (isFlipRight) { rotation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0.0f, 1.0f, 0.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f)],nil];

} else { rotation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0.0f, 1.0f, 0.0f)],nil];

}

[[arrowImageView layer] addAnimation:rotation forKey:@"transform"];

Répondre

1

Ajoutez cette ligne avant d'appeler addAnimation ..

rotation.fillMode = kCAFillModeForwards; 
+0

Merci - été à la recherche de cette matinée! – SomaMan