How does [UIView beginAnimations] work?

前端 未结 2 1419
渐次进展
渐次进展 2021-02-19 19:08

I was wondering how animations work in Cocoa Touch. For example:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];

view1.alpha = 1.0         


        
2条回答
  •  野的像风
    2021-02-19 19:42

    A simplified explanation:

    All animations for all views are handled on a single stack, beginAnimations:context: will push a new active CAAnimationGroup on the stack, and commitAnimations will pop the current active animation group.

    If there is an active animation group on the stack, then all setters for animatable properties will create CAAnimation subclass instances to handle that property and add then to the active animation group.

    When the last animation is popped, it is replayed.

提交回复
热议问题