如何在动画时获取UIView帧的原点和大小 [英] How to get UIView frame origin and size while animation

查看:124
本文介绍了如何在动画时获取UIView帧的原点和大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆