LoginSignup
2
1

More than 5 years have passed since last update.

animateWithDuration実行時にユーザー入力を受け付けるためには

Posted at

画像などの表示時にふわぁ〜っという感じで表示させることがあるかと思います。
しかし、下記のように実装してしまうと、アニメーション実行最中は画面タップに反応しなくなってしまいます。

option未指定
imageView.alpha = 0.0;
[UIView animateWithDuration:0.8
                 animations:^{
                     imageView.alpha = 1.0;
                 }];

animateWithDurationにはoptionを指定できるメソッドが用意されているので、下記のようにUserInteractionを有効化してあげると、思った通りの動作をするようです。

option指定
imageView.alpha = 0.0;
[UIView animateWithDuration:0.8
                      delay:0
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                     imageView.alpha = 1.0;
                 }
                 completion:nil];
2
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
2
1