Essaie de retarder CABasicAnimation la position et l'opacité de la couche de 3 secondes mais

Je suis en train d'essayer de retarder l'animation de l'opacité du calque et de la positionner en 3 secondes à l'aide d'setBeginTime. J'ai appelé la couche boxLayer. L'animation se déroule bien, mais pendant les 3 premières secondes (la couche n'est pas censé montrer encore) la couche est affichée à la position finale et de l'opacité. Il ne devrait pas. Animation de groupe ne permet pas de résoudre le problème. Quelqu'un pourrait-il aider? Voir le code ci-dessous:

//Create an animation that will change the opacity of a layer
CABasicAnimation *fader = [CABasicAnimation animationWithKeyPath:@"opacity"];


//It will last 1 second and will be delayed by 3 seconds
[fader setDuration:1.0];
[fader setBeginTime:CACurrentMediaTime()+3.0];


//The layer's opacity will start at 0.0 (completely transparent)
[fader setFromValue:[NSNumber numberWithFloat:startOpacity]];

//And the layer will end at 1.0 (completely opaque)
[fader setToValue:[NSNumber numberWithFloat:endOpacity]];

//Add it to the layer
[boxLayer addAnimation:fader forKey:@"BigFade"];

//Maintain opacity to 1.0 JUST TO MAKE SURE IT DOES NOT GO BACK TO ORIGINAL OPACITY
[boxLayer setOpacity:endOpacity];


//Create an animation that will change the position of a layer
CABasicAnimation *mover = [CABasicAnimation animationWithKeyPath:@"position"];

//It will last 1 second and will be delayed by 3 seconds
[mover setDuration:1.0];
[mover setBeginTime:CACurrentMediaTime()+3.0];

//Setting starting position
[mover setFromValue:[NSValue valueWithCGPoint:CGPointMake(startX, startY)]];

//Setting ending position
[mover setToValue:[NSValue valueWithCGPoint:CGPointMake(endX, endY)]];

//Add it to the layer
[boxLayer addAnimation:mover forKey:@"BigMove"];

//Maintain the end position at 400.0 450.0 OTHERWISE IT IS GOING BACK TO ORIGINAL POSITION
[boxLayer setPosition:CGPointMake(endX, endY)];
comment le fait de faire une méthode de type [auto performSelector:@selector(methodname) withObject:néant afterDelay:3.0 f]; ou à l'aide de sleep();
Mon problème n'est pas le retard de l'animation, mais plutôt le fait que la couche est affichée avant le retard de l'animation commence.

OriginalL'auteur Armand | 2013-01-30