How to cancel UIView block-based animation?

前端 未结 4 1553
栀梦
栀梦 2020-11-29 04:22

I\'ve searched loads of SO stuff and in Apple\'s references, but still unable to manage my problem.

What I have:

  1. A screen with 2 UIImageView
4条回答
  •  Happy的楠姐
    2020-11-29 04:51

    You can stop all animations on a view by calling:

    [view.layer removeAllAnimations];
    

    (You'll need to import the QuartzCore framework to call methods on view.layer).

    If you want to stop a specific animation, not all animations, your best best bet is to use CAAnimations explicitly rather than the UIView animation helper methods, then you will have more granular control and can stop animations explicitly by name.

    The Apple Core Animation documentation can be found here:

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/CreatingBasicAnimations/CreatingBasicAnimations.html

提交回复
热议问题