本文介绍了[UIView beginAnimations]如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道动画如何在Cocoa Touch中工作。例如:

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

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

view1.alpha = 1.0;
view2.frame.origin.x += 100;

[UIView commitAnimations];

如何使用UIView 跟踪属性的两个视图?

How does UIView tracks the changes to the properties of the two views?

我怀疑KVO是使用,但它真的观察到 beginAnimations commitAnimations 调用?

I suspect that KVO is used, but does it really observe the changes to every views between the beginAnimations and commitAnimations calls?

推荐答案

简单说明:

所有视图的所有动画都在单个堆栈中处理, beginAnimations:context:将在堆栈上推送一个新的活动 CAAnimationGroup commitAnimations 将弹出当前活动动画组。

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.

如果堆栈上有一个活动的动画组,那么所有动画属性的setter将创建 CAAnimation 子类实例来处理该属性,然后将其添加到活动动画组。

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.

这篇关于[UIView beginAnimations]如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 22:06