Ich versuche, die Animation der Deckkraft und Position der Ebene um 3 Sekunden mit SetBeginTime zu verzögern. Ich habe den Layer boxLayer aufgerufen. Die Animation läuft gut, aber während der ersten 3 Sekunden (die Ebene soll noch nicht angezeigt werden) wird die Ebene an ihrer endgültigen Position und Opazität angezeigt. Es sollte nicht. Gruppenanimation löst das Problem nicht. Könnte jemand helfen? Siehe Code unten:Versuchen CABasicAnimation Position und Deckkraft der Ebene um 3 Sekunden zu verzögern, aber
// 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)];
, wie etwa ein Verfahren wie die Herstellung [self perform: @selector (Methodenname) withobject: nil afterDelay: 3.0f]; oder mithilfe von sleep(); –
Mein Problem ist nicht die verzögerte Animation, sondern die Tatsache, dass die Ebene angezeigt wird, bevor die verzögerte Animation startet. – Armand