How UIView animations with blocks work under the hood

前端 未结 3 674
伪装坚强ぢ
伪装坚强ぢ 2020-12-31 02:18

I\'m new to Objective-C/iOS programming and I\'m trying to understand how UIView animation works under the hood.

Say I have a code like this:

[UIView         


        
3条回答
  •  清酒与你
    2020-12-31 02:59

    The values intermediate frames for are not specified; the animation of the values (alpha in this case, but also colours, position, etc) is generated automatically between the previously set value and the destination value set inside the animation block. You can affect the curve by specifying the options using animateWithDuration:delay:options:animations:completion: (the default is UIViewAnimationOptionCurveEaseInOut, i.e., the speed of the value change will accelerate and decelerate).

    Note that any previously set animated changes of values will finish first, i.e., each animation block specifies a new animation from the previous end value to the new. You can specify UIViewAnimationOptionBeginFromCurrentState to start the new animation from the state of the already in-progress animation.

提交回复
热议问题