2012-08-27 4 views
0

Je suis en train de mettre en œuvre l'animation suivante:animation de groupe UIView

yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01); 
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 
//change time duration according to requirement 
// animate it to the identity transform (100% scale) 
yourSubView.transform = CGAffineTransformIdentity; 
} completion:^(BOOL finished){ 
// if you want to do something once the animation finishes, put it here 
}]; 

combiné avec un mouvement de la sous-vue. Je sais que dans l'animation de base, vous pouvez combiner des animations, mais comment pouvez-vous faire cela dans l'animation UIView? Est-ce que je peux traduire ce code de l'animation UIView vers l'animation Core?

yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01); 
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 
//change time duration according to requirement 
// animate it to the identity transform (100% scale) 
yourSubView.transform = CGAffineTransformIdentity; 
} completion:^(BOOL finished){ 
// if you want to do something once the animation finishes, put it here 
}]; 

Répondre

2

Vous pouvez combiner des animations en modifiant plusieurs propriétés animables. Par exemple, vous pouvez également définir votreSubView.alpha, puis modifier l'alpha dans le bloc d'animation. Il combinera l'échelle et le changement d'alpha ensemble.

Pour faire une traduction simple, essayez dans votre bloc d'animation:

yourSubView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 100.0, 100.0); 

cela devrait définir l'échelle de retour à l'identité ainsi que le déplacement dans 100px x et y.

Pour Core Animation, ce Grouping two Core Animations with CAAnimationGroup causes one CABasicAnimation to not run devrait vous aider à démarrer. Vous utiliserez un CAAnimationGroup pour combiner plusieurs animations, et vous pourrez faire des choses assez fantaisistes, y compris la rotation 3D.

Normalisation:

CAKeyframeAnimation *scale = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; 
[scale setValues:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.01f],[NSNumber numberWithFloat:1.0f],nil]]; 
[scale setKeyTimes:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.4f],nil]]; 

[mySubview.layer addAnimation:scale forKey:@"myScale"]; 
+0

comment peut convertir le code de l'animation de base: yourSubView.transform = CGAffineTransformMakeScale (0,01, 0,01); [UIView animateWithDuration: 0,4 Retard: 0 Options: animations UIViewAnimationOptionCurveEaseOut:^{// durée de changement selon l'exigence // animer à l'identité de transformation (100% échelle) yourSubView.transform = CGAffineTransformIdentity; } achèvement:^(BOOL terminé) { // si vous voulez faire quelque chose une fois l'animation terminée, mettez-la ici }]; – Juan

+0

a modifié la réponse pour afficher l'exemple pour la mise à l'échelle – CSmith