Why is -animateWithDuration:delay:options:animations:completion: blocking the UI?

I always thought that Core Animation performs animations on the background. When I run this code, my UI interactions are blocked until the animation finishes:

[UIView animateWithDuration:4.5 
                      delay:0 
                    options:options 
                 animations:^{
                    oldView.alpha = 0;
                    newView.alpha = 1;
                 }  
                 completion:^(BOOL finished) {
                    if (finished) {
                        [oldView removeFromSuperview];
                    }
                 }];

Like you can see the duration is long so it’s clearly visible that the UI interactions are blocked while animating.

  • Frame is not changing in cellForRowAtIndexPath
  • Move a node to finger using Swift + SpriteKit
  • Autoscrolling in a UIScrollview
  • AVPlayer wont play video from url in iOS9
  • How to get available wifi network name in iOS using swift
  • After retrieving data from Firebase, how to send retrieved data from one view controller to another view controller?
  • The UI interaction begins to be blocked when the animation begins, and ends to be blocked when the animation finishes.

    Is there a way to start a UIView animation concurrently so the UI interactions are not blocked?

    EDIT to clarify: I know that the UI is blocked because I cannot interact with any control on the screen why this animation is running. Those other controls are not related with what is being animated and are not on the same branch in the view hierarchy. The entire UI is blocked when this animation runs. When I set it to 10 seconds, the UI is blocked for 10 seconds while the animation runs. Tested with iOS 4.2 on iPhone 4.

    2 Solutions Collect From Internet About “Why is -animateWithDuration:delay:options:animations:completion: blocking the UI?”

    Looking at the documentation for UIView, I found this in the discussion section for that method:

    During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the UIViewAnimationOptionAllowUserInteraction constant in the options parameter.

    So, if you want user interaction to continue to be allowed, you must set this constant in the options parameter.

    Documentation is your friend 🙂

    UIView Class Reference

    Under animateWithDuration:animations:

    “During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)”

    And of course, for all views under the animated view.