How to recognize tap gesture while a view is animating

后端 未结 3 1031
慢半拍i
慢半拍i 2021-02-08 20:09

Just wondering is there way to have a view recognize tap gestures while it is being animated? I am working on a view that has a cashapelayer line tethered to it. When the user p

相关标签:
3条回答
  • 2021-02-08 20:41

    (Swift 3) Pass .allowUserInteraction option

    UIView.animate(withDuration: 0.75, delay: 0.0, options: [.allowUserInteraction], animations: {
          // Desired animation(s) 
    }, completion: { (finished: Bool) in
            // Completion
    })
    
    0 讨论(0)
  • 2021-02-08 20:46

    I'm assuming that you are using the [UIView animateWithDuration: delay: options: animations: completion:]; method of animating.

    If so, you need to pass UIViewAnimationOptionAllowUserInteraction as an option to get the animated view to respond to touches while it is animating.

    0 讨论(0)
  • 2021-02-08 20:46

    You need to set two options - UIViewAnimationOptionAllowUserInteraction and UIViewAnimationOptionAllowAnimatedContent. First lets you interact with views during animation, second forces to redraw views on every frame of animation and not use snapshots of beginning and ending frames.

    0 讨论(0)
提交回复
热议问题