如何使Uilabel动画另一个



我当前动画两个UILabel这样:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[_temperatureLabel setAlpha:1];
[_tempDescriptionLabel setAlpha:1];
[UIView commitAnimations];

但是,我想显示第一个标签_temperatureLabel,然后一旦完成动画(或可能是中途),请开始对第二个标签_tempDescriptionLabel进行动画。

正如我所说的,我会回答:

 [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
         //set alpha 1 for first UILabel
         _temperatureLabel.alpha = 1;
        } completion:^(BOOL finished){
        [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
                //when finished enter here
            //set alpha 1 for second UILabel
            _tempDescriptionLabel.alpha = 1;
            } completion:^(BOOL finished){

            }];
        }];

记住添加QuartzCore框架,然后添加#import <QuartzCore/QuartzCore.h>

用于中途或其他任何中途时间,

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[_temperatureLabel setAlpha:1];
[UIView commitAnimations];
[self performSelector:@selector(halfWayStart:) withObject:nil afterDelay:1.0];
-(void)halfWayStart:(id)object{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2.0];
    [_tempDescriptionLabel setAlpha:1];
    [UIView commitAnimations];
}

因此,更改afterDelay performSelector呼叫中的时间值将帮助您随时启动其他动画。

最新更新