首页 > 解决方案 > UIAlertController freezes the UI when presented after pausing the layer animation

问题描述

In a ViewController, I am performing a transition animation on a view. On a button action, the transition animation is paused by setting the layer speed equals to zero.

But, when the alert is presented over the screen after pausing the animation, the UI freezes and when I move the app from foreground to background and then again to foreground after some time, the alert action starts working. Does anybody have an idea of this issue?

func pauseLayer(layer: CALayer) {
    let pausedTime: CFTimeInterval = layer.convertTime(CACurrentMediaTime(), from: nil)
    layer.speed = 0.0
    layer.timeOffset = pausedTime
}

Code for animation:

UIView.transition(with: self.rotatingView, duration: 1.0, options: [.transitionFlipFromLeft], animations: {
        }) { (true) in
        //    print("completed")
        }

标签: iosswiftuiviewanimationtransition

解决方案


推荐阅读