views:

219

answers:

1

Hi,

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 begins. 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!

+2  A: 

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.

Brad Larson
thanks for letting me know! I'll try to figure out how I can observe the property manually in my code.
cocoaholic