Frage

Ich möchte eine Einblendung tun und aus einem UIImageView unterschiedlichen Zeiten mit, sagen wir mal, mit den folgenden Parametern:

  • t = 0 ... UIImageView des alpha = 0
  • t = 0,5 s ... UIImageView der alpha = 0,7
  • t = 0.7s ... UIImageView des alpha = 0

Ist das möglich mit CAAnimation oder einem anderen Methode zu tun? Wie kann das geschehen?

Dank für jede Hilfe!

War es hilfreich?

Lösung

Sie sollten wahrscheinlich in CAKeyframeAnimation aussehen. Es lasse Sie Werte für mehrere Zeitpunkte festgelegt.

Andere Tipps

if (imgDefault.alpha == 0.0) {
    CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration: 3.0];
        [UIView setAnimationDelegate: self];
        imgDefault.alpha = 1.0;
        [UIView commitAnimations];
}
else {
    CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration: 3.0];
        [UIView setAnimationDelegate: self];
        imgDefault.alpha = 0.0;
        [UIView commitAnimations];
}

Hoffnung, es hilft

UIView hat eine setAnimationDidStopSelector: Methode, die Sie verwenden können. Einfach Setup Ihre verblassen in der Animation ein beginAnimations Block und stellen Sie den didStop Wähler auf eine andere Methode, die aus Animation Block nur die Fade enthält verwenden. Jede dieser Animation Blöcke können verschiedene Animationsdauern haben.

So etwas wie folgt aus:

    [UIView beginAnimations:next context:context];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(fadeOut:finished:context:)];
    myView.alpha = 0.7;
    [UIView commitAnimations];

-(void)fadeOut:(NSString*)animationID finished:(BOOL)finished context:(void*)context  {
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationDuration:0.2];
    myView.alpha = 0.0;
    [UIView commitAnimations];
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top