Key value Observation during UIView animation

I am animating the properties of a view center in my program. During the animation, I need notifications when the center falls into a certain value.

I tried to add myself as an observer of key values โ€‹โ€‹for the center of view property. However, I receive a notification only after the start of the animation. Therefore, I cannot determine if / when an object passes through my point of interest.

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

Thanks!

+3
source share
1 answer

You can get values โ€‹โ€‹representing the current state of the UIView animation level by accessing its presentation level. This can be done using the following code:

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

Unfortunately, the properties of the presentation layer do not meet the requirements of KVO, so the best way I can come up with to track the current value is to view the survey of the presentation level until it approaches the desired location.

+6
source

All Articles