Question

Je peux animer l’ajout d’un UIView à mon application, elle est très jolie, alors merci Apple.

Cependant, comment puis-je animer la suppression de cette vue de la super vue?

J'utilise:

CATransition *animation = [CATransition animation];
[animation setDuration:1];
[animation setType:kCATransitionReveal];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[myview layer] addAnimation:animation forKey:kCATransitionReveal];

pour animer le " dans " transition ... comment animez-vous le " out " transition ????

Était-ce utile?

La solution

Animez votre vue de manière à ce qu'elle passe hors de l'écran / se rétrécisse / se développe / disparaisse progressivement, puis effectuez la suppression à la fin de l'animation.

Vous pouvez le faire en modifiant les propriétés de la vue (position / taille / décalage) entre un bloc beginAnimations / commitAnimations. UIKit animera ensuite ces propriétés sur la durée spécifiée.

E.g quelque chose comme:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.30f];
view.transform = 
  CGAffineTransformMakeTranslation(
    view.frame.origin.x, 
    480.0f + (view.frame.size.height/2)  // move the whole view offscreen
  );
background.alpha = 0; // also fade to transparent
[UIView commitAnimations];

Dans la notification de fin d'animation, vous pouvez ensuite supprimer la vue.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top