UIView的动画确定动画期间中心 [英] UIView animation determine center during animation

查看:156
本文介绍了UIView的动画确定动画期间中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的UIView的 + animateWithDuration:延迟:选项:动画:完成:方法在几秒钟左右的过程中沿直线移动我的观点。

I'm using UIView's + animateWithDuration:delay:options:animations:completion: method to move my view along a line over the course of a few seconds or so.

我想这个动画,其中UIView的是随着它的移动路径时确定,在任意时间。然而,当我做到这一点,尝试访问中心,我发现位置已被设置为它的最终目的地。

I would like to determine, at an arbitrary time during this animation, where the UIView is along with path it is moving. However when I do this and try and access center or frame, I find that the location is already set to it's final destination.

我这样做的原因是,我有一个的NSTimer每0.1秒(或左右),这将更新父视图来显示一条线,其中的UIView有previously了射击。我希望能够保持这个更新UIView的动作。

The reason I'm doing this is that I've got an NSTimer firing every 0.1 seconds (or thereabouts) which will update the parent view to show a line where the UIView has previously been. I want to be able to keep this updated as the UIView moves.

这是如何做到这一点任何想法?唯一的类似的问题,我发现了 http://forums.macrumors.com/showthread.php? T = 1056105 ,但没有显示分辨率。

Any ideas on how to do this? The only similar question I found was http://forums.macrumors.com/showthread.php?t=1056105, but there is no resolution shown.

另外...有什么更好的办法来做到这一点?

Alternatively...are there any better ways to do this?

谢谢!

推荐答案

UIViews由CALayers的支持,这是不实际的动画层。 CALayer的公开属性 presentationLayer 其中,访问时,尽可能接近,因为它可以返回的CALayer的重新presents,副本,目前的状态可见用户。通过询问的 view.layer。presentationLayer.frame 就可以得到以用户为可见层的框架,现在,与此相对应的框架UIView的。

UIViews are backed by CALayers, and it is the layer that does the actual animation. CALayer exposes a property presentationLayer which, when accessed, returns a copy of the CALayer that represents, as closely as it can, the current state visible to the user. By asking for the view.layer.presentationLayer.frame you can get the frame of the layer as visible to the user right now, and this corresponds to the frame of the UIView.

这篇关于UIView的动画确定动画期间中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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