如何在动画时获取UIView帧的原点和大小 [英] How to get UIView frame origin and size while 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];
和带回调方法的NSTimer。问题:是否有可能在计时器回调方法中获取当前的myview.frame大小和原点?
或者可能有另一种方法来跟踪它?
and NSTimer with callback method. The question: is it possible to get current myview.frame size and origin inside timer callback method?
or may be there is another way to trace it?
推荐答案
我很确定这是不可能的,因为当您更改视图的 框架
时立即生效。在后台,核心动画
负责动画。所以,即使你可以抓住框架,它也会给你最终的坐标,而不是动画中的当前坐标。
I'm pretty sure that it's not possible, because when you change the frame
of your view it takes effect immediately. In the background, Core Animation
takes care of the animation. So, even if you could grab the frame, it'd give you the final coordinates, not the current coordinates in the midst of an animation.
访问属性的表示层,如评论中的 NWCoder
所指出的那样。请参阅 文档 。
Access the presentation layer of the property, as pointed out by NWCoder
in the comments. See the documentation.
[view.layer.presentationLayer frame]
这篇关于如何在动画时获取UIView帧的原点和大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!