LoginSignup
0
1

More than 1 year has passed since last update.

[swift]UIView.animate()をしたら余計なアニメーションが追加されて困った

Last updated at Posted at 2019-04-22

はじめに

UIButtonをアニメーションさせたいと思い、UIView.animate()メソッドを実行したところアニメーション終了後に別の余計なアニメーションが加わり、全然思い通りに動いてくれませんでした。

随分長いこと悩まされたので備忘録的にメモ

原因

今回、UIView.animate()の他にCAKeyframeAnimationも併用して使っていたのですが、その際にadd(animation, forKey:)していたアニメーションが残っていたようです。

解決法

適切な位置でremoveAllAnimation()を呼び出すことで解決しました。

終わりに

検証はしていませんが、UIView.animate()を実行すると、add(animation, forKey:)されたアニメーションも一緒に実行される?みたいです。

まだそれぞれのanimationの違いもよくわかっていない状態なので、詳しい方がいたら教えていただきたいです......

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1