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

后端 未结 2 650
醉酒成梦
醉酒成梦 2021-01-18 03:36

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:



        
相关标签:
2条回答
  • 2021-01-18 03:44

    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.

    0 讨论(0)
  • 2021-01-18 04:00

    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.

    0 讨论(0)
提交回复
热议问题