开发者

UIView Animations with Objective-C Blocks

开发者 https://www.devze.com 2023-02-12 08:46 出处:网络
I have been playing around with the two different ways of doing UIView animations: begin/commit and Blocks.

I have been playing around with the two different ways of doing UIView animations: begin/commit and Blocks.

I have noticed that the beginAnimations:context: / commitAnimations way of doing things is nicely asynchronous, keeping the UI free while the animation is running.

However, I also noticed that the animateWithDuration:animations:completion way seems to block the UI, making it unresponsive while the animation is running.

I thought one of the main points of using blocks was to achieve asynchronous execution easily. Why does the blocks variant of the UIView animarions block the UI while the begin/commit variant does not?

Edit:

My question origi开发者_开发问答nally assumed that the blocks animation was a synchronous operation and blocked the UI. As it transpired from Jeff Kelly's answer, that this isn't the case. My original assumption was incorrect, the blocks animation is not synchronous. See Jeff's answer for the details.


Are you using the right UIView class method? If you use +animateWithDuration:delay:options:animations:completion:, you can specify a bitmask of options. One of the possible options is UIViewAnimationOptionAllowUserInteraction, which sounds like just what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消