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

将来のコードの再利用とコードをきれいに保つためのust

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 に答える