UIView animateWithDuration 跳转到最终变换没有动画

UIView animateWithDuration jumps to final transform without animation

我有以下代码来创建翻转过渡。 fromView 不会对变换进行动画处理并跳转到最终值,但 toView 会正确地对变换进行动画处理。这里可能有什么问题?

  toView.hidden = NO;
  toView.transform = CGAffineTransformMake(0, 0, 0, 1, 0, 0);
  [UIView animateWithDuration:0.4
                   animations:^{
                     fromView.transform = CGAffineTransformMake(0, 0, 0, 1, 0, 0);
                   }
                   completion:^(BOOL finished) {
                     fromView.hidden = YES;
                     fromView.transform = CGAffineTransformIdentity;
                     [UIView animateWithDuration:0.4
                                      animations:^{
                                        toView.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
                                      }
                                      completion:nil];
                   }];

我认为比例不能动画化为 0 值,因为转换矩阵中存在被零除的问题。

在此 link 中查看。 http://www.wenda.io/questions/217747/uiview-scale-to-0-using-cgaffinetransformmakescale.html

还有这个CGAffineTransformMakeScale animation not working

您可以改为使用较小的值进行缩放,然后隐藏视图,如下所示

[UIView animateWithDuration:0.4
                     animations:^{
                         fromView.transform = CGAffineTransformMakeScale(0.01, 1);
                     }
                     completion:^(BOOL finished) {
                         fromView.hidden = YES;
                         fromView.transform = CGAffineTransformIdentity;
                         [UIView animateWithDuration:0.4
                                          animations:^{
                                              toView.transform = CGAffineTransformMakeScale(1, 1);
                                          }
                                          completion:nil];
                     }];