如何为UILabel设置一个又一个的动画

时间:2014-01-31 15:43:36

标签: ios objective-c uilabel

我目前以两个UILabel为动画:

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

但是,我希望显示第一个标签_temperatureLabel然后一旦完成动画(或者可能是中途)开始动画第二个标签_tempDescriptionLabel

2 个答案:

答案 0 :(得分:2)

正如我所说,我会回答:

 [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>

答案 1 :(得分:0)

为了做半途或任何其他中途时间,

[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时间值将有助于您随时启动其他动画。