Stop an auto-reverse / infinite-repeat UIView animation with a BOOL / completion block

前端 未结 4 1322
刺人心
刺人心 2021-01-01 11:06

I\'m setting up the following UIView animateWithDuration: method, with the intention of setting my animationOn BOOL elsewhere in the program to can

4条回答
  •  感动是毒
    2021-01-01 11:37

    The completion block will only get called when the animation is interrupted. For example it gets called when the app goes in the background and comes back to the foreground again (via multitasking). In that case the animation is stopped. You should restart the animation when that happens.

    To stop the animation you can remove it from the view's layer:

    [button.layer removeAllAnimations];
    

提交回复
热议问题