How to cancel UIView block-based animation?

前端 未结 4 1563
栀梦
栀梦 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条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 04:58

    You can try this (in Swift):

    UIView.setAnimationsEnabled(false)
    UIView.setAnimationsEnabled(true)
    

    Note: you can put code between those two calls if necessary, for example:

    UIView.setAnimationsEnabled(false)
    aview.layer.removeAllAnimations() // remove layer based animations e.g. aview.layer.opacity
    UIView.setAnimationsEnabled(true)
    

提交回复
热议问题