如何在动画时获取UIView帧的原点和大小

hex*_*mal 9 iphone core-animation

我有UIView动画

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:25]; 
myview.frame = CGRectMake(218, 216, myview.frame.size.width * 0.5, myview.frame.size.height * 0.5);
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

和NSTimer的回调方法.问题:是否有可能在计时器回调方法中获取当前的myview.frame大小和原点?
或者可能有另一种方法来追踪它?

sud*_*-rf 12

我很确定这是不可能的,因为当你改变frame视图时它会立即生效.在后台,Core Animation照顾动画.所以,即使你可以抓住框架,它也会给你最终的坐标,而不是动画中的当前坐标.

NWCoder评论中所指出的,访问属性的表示层.请参阅文档.

[view.layer.presentationLayer frame]
Run Code Online (Sandbox Code Playgroud)

  • 如果有人仍然需要这个,那就有可能.您可以使用:[[v.layer presentationLayer] frame]; (9认同)