动画颜色从上到下变化,反之亦然

Animating color changes from top to bottom and vice versa

我正在尝试按如下方式设置颜色变化动画:

[UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionCurveEaseIn animations:^{
    self.view.backgroundColor = [UIColor greenColor];
} completion:^(BOOL finished)
 {
     NSLog(@"Color transformation Completed");
     [UIView animateWithDuration:1.0 delay:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{
         self.view.backgroundColor = [UIColor whiteColor];
     } completion:^(BOOL finished)
      {
          NSLog(@"Color transformation Completed");
      }

      ];
 }
 ];

我希望颜色从上到下流动,因为它用绿色填充整个屏幕,它应该从下到上填充白色。

所以我在填充绿色时使用了UIViewAnimationOptionCurveEaseIn,在填充白色时使用了options:UIViewAnimationOptionCurveEaseOut,但我无法获得预期的效果..为什么这样?

options 仅描述您的动画将如何运作。例如,EaseIn表示动画的速度先慢后快。

所以如果你想实现这个动画,你可以设置 2 个 UIView 为绿色和白色,然后通过动画改变它们的 frame