开发者

Key value Observing during UIView Animations

I'm animating the center property of a view in my program. During the animation, I need notifications when center hits a particular value.

I tried adding the myself as a key value observer for the center property of the view . However, I only get notified when the animation be开发者_开发技巧gins. So I'm unable to detect if/when the object passes through my point of interest.

Is there a way to do this through KVO or any other method?

Thanks!


You can retrieve the values representing the current state of the UIView's animating layer by accessing its presentation layer. This can be done using code like the following:

CGPoint currentCenter = [[view.layer presentationLayer] center];

Unfortunately, the presentation layer's properties are not KVO-compliant, so the best way I can think of for tracking the current value is to keep polling the presentation layer until it gets near the location you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜