CGRect frame= self.bg.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
long tag=sender.tag;
switch (tag) {
case 10:
frame.origin.y-=30;
break;
case 20:
frame.origin.y+=30;
break;
default:
break;
}
self.bg.frame=frame;
[UIView commitAnimations];
中间这部分代码将被执行动画。
我有一个比较奇葩的问题,就是这部分动画代码,编译器是如何获得的呢?
我的心里是这么想的,当然是伪代码表述:就是用String去截取,把这段代码截取出来去执行。。
求教。。
还有顺便一个问题,我一起问了吧。
self.bg.frame=frame;这样位置就变了。。那么OC或者说IOS肯定是不断监听这个属性的变化的。。那么IOS中事件模型是怎样的呢?
There is another way, which is that it must be executed sequentially. . . Only when commitAnimations is reached is the actual submission.
The result of the operation:
2015-08-28 1520.020 02 Calculator [1403:73936] The execution reaches here beginAnimations
2015-08-28 1520.021 02 Calculator [1403:73936] Execution reaches here setAnimationDuration
2015-08-28 1520.022 02Calculator[1403:73936] Execution reaches here 2
2015-08-28 1520.022 02Calculator[1403:73936] commitAnimations
That is to say, the code must be executed sequentially. . There is no mention of extracting the code and executing it. self.bg.frame=frame; When executing, there must be something similar to obtaining animation status. .
google: render tree, render tree