UILabel animation oben und unten
Habe ich diese UILabel
animation, animiert, einen countdown-timer. Es funktioniert gut, aber...
Jetzt, es ist so eingerichtet, dass der text vereinfacht aus der Spitze mit der CATransition
kCATransitionFromBottom
. Dies dauert 0,5 Sekunden. Wie kann ich es so machen, dass in den nächsten 0,5 Sekunden, die CATransition
und mein label erleichtert von unten?
Hoffe, Sie verstehen! Danke!
Hier ist ein video wie die animation aussieht im Moment: http://tinypic.com/r/5vst2h/8
-(void)updateLabel {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
int *units = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *components = [calendar components:units fromDate:[NSDate date] toDate:destinationDate options:0];
//ANIMASJON
secLabel.alpha = 0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//don't forget to add delegate.....
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
secLabel.alpha = 1;
//also call this before commit animations......
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
CATransition *animation = [CATransition animation];
animation.duration = 0.5; //You can change this to any other duration
animation.type = kCATransitionMoveIn; //I would assume this is what you want because you want to "animate up or down"
animation.subtype = kCATransitionFromBottom; //You can change this to kCATransitionFromBottom, kCATransitionFromLeft, or kCATransitionFromRight
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[secLabel.layer addAnimation:animation forKey:@"secLabel"];
[dayLabel setText:[NSString stringWithFormat:@"%02d%", [components day]]];
[hourLabel setText:[NSString stringWithFormat:@"%02d%", [components hour]]];
[minLabel setText:[NSString stringWithFormat:@"%02d%", [components minute]]];
[secLabel setText:[NSString stringWithFormat:@"%02d%", [components second]]];
[UIView commitAnimations];
}
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
secLabel.alpha = 0;
[UIView commitAnimations];
}
}
Du musst angemeldet sein, um einen Kommentar abzugeben.
Animieren Etikett nach oben, dann nach unten, ich in der Regel tun Sie dies:
Ist, dass das, was du suchst?
Bearbeiten
Recht, lese deine Frage noch einmal, so dass Sie wollen, slide & fade-in aus der Spitze und schieben Sie dann & ausblenden nach unten?
Beachten Transformationen angewendet werden relative dein frame ist original x -, y -, width -, height-Eigenschaften. So ein übersetzen von 100 Einheiten in y bedeutet, dass den Rahmen die ursprüngliche Y-Koordinate + 100.
Haben Sie versucht, die Animation Blöcke. Vielleicht eine animation block innerhalb der completion-block tun kann, die gewünschten Ergebnisse. So etwas wie dieses: (unter Berücksichtigung der y-Punkt auf Ihrem Etikett irgendwo auf der Oberseite)
Hoffe, Sie bekommen eine Idee von diesem.