3

我正在尝试为下面的动画添加反弹效果。这是我的代码:

[UIView animateWithDuration:1.0
                       delay:.0
      usingSpringWithDamping:0.5
       initialSpringVelocity:2.0
                     options:UIViewAnimationOptionCurveEaseOut
                  animations:^{
                      // Coming from a value of CGAffineTransformMakeScale(0.001, 1.0)
                      self.myView.transform = CGAffineTransformMakeScale(1.0, 1.0);
                  }completion:nil
          ];

它无法正常工作。它在动画结束时变宽,然后恢复正常。我希望宽度反弹到小于 1.0 的值,不超过 1.0。

4

2 回答 2

9

用于将来的代码重用并保持代码干净

popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);

[self.view addSubview:popUp];

[UIView animateWithDuration:0.3/1.5 animations:^{
    popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.3/2 animations:^{
        popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3/2 animations:^{
            popUp.transform = CGAffineTransformIdentity;                            
        }];
    }];
}];
于 2015-05-06T07:07:25.280 回答
2

UIView 弹跳动画在这篇文章中给出了详细的解释,UIDynamicAnimator 和 spring Animation 都有

如何创建 UIView 弹跳动画?

于 2015-05-06T07:22:30.950 回答