显示UILabel动画

Alb*_*rez 2 iphone core-animation objective-c uilabel ios

我需要显示一条带动画的消息,并在几秒钟后用动画隐藏.

有谁知道这有可能吗?

非常感谢你所做的一切.

问候

Sri*_*aju 12

它很容易,尝试将动画链接在一起.先淡出,然后淡出.下面的代码首先设置alpha为0.然后在1秒内为标签的外观设置动画.一旦完成,等待4秒,然后以相同的方式启动fadeOut动画.

[label setText:@"some text"];
[label setAlpha:0.0];
[UIView animateWithDuration:1.0 
                      delay:0 
                    options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
                 animations:^(void) 
 {
     [label setAlpha:1.0];
 } 
                 completion:^(BOOL finished) 
 {
     if(finished)
     {
         [UIView animateWithDuration:1.5 
                               delay:4 
                             options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
                          animations:^(void) 
          {
              [label setAlpha:0.0];
          } 
                          completion:^(BOOL finished) 
          {
              if(finished)
                  NSLog(@"Hurray. Label fadedIn & fadedOut");
          }];
     }
 }];
Run Code Online (Sandbox Code Playgroud)

这种在iOS中链接动画的方式是最有效的方法之一.