如何将反弹效果添加到UIView animateWithDuration

Eri*_*ric 3 animation objective-c ios animatewithduration

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

[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
          ];
Run Code Online (Sandbox Code Playgroud)

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

Vij*_*dav 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;                            
        }];
    }];
}];
Run Code Online (Sandbox Code Playgroud)