2010-03-31 4 views
3

J'ai ajouté un CALayer au UIView de mon application:Comment transformer (tourner) un calayer/animation déjà existant?

CATransition *animation = [CATransition animation]; 
    [animation setDelegate:self]; 
    [animation setDuration:0.35]; 
    [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 
     animation.type = @"pageCurl"; 
     animation.fillMode = kCAFillModeForwards; 
     animation.endProgress = 0.58; 
    [animation setRemovedOnCompletion:NO]; 
    [[self.view layer] addAnimation:animation forKey:@"pageCurlAnimation"]; 

Maintenant, lorsque l'utilisateur fait tourner le dispositif, la couche reste toujours dans la même position sur l'écran (en ligne sur la touche écran d'accueil). Est-il possible de faire pivoter l'animation/couche? J'ai essayé

self.view.layer.transform = CGAffineTransformMakeRotation (angle); 

mais ce code tourne juste le UIView et non l'animation/couche I mis.

Répondre

4

L'erreur est due au fait que le type de la propriété de transformation de CALayer est CATransform3D et que vous lui attribuez une valeur CGAffineTransform. Utiliser CATransform3D CATransform3DMakeRotation (angle CGFloat, CGFloat x, CGFloat y, CGFloat z); à la place.

Questions connexes