Key value Observing during UIView Animations

后端 未结 1 916
心在旅途
心在旅途 2021-01-13 12:25

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

相关标签:
1条回答
  • 2021-01-13 13:23

    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 讨论(0)
提交回复
热议问题