iPhone app crashes when CALayer is paused and view is rotated

I have an app with a UIImage animating. When I pause the animation and rotate the screen, the app hangs with only half the image filling the view. I'm assuming the image can't update to the correct aspect ratio because the layer is paused which is what causes the hang.

If it matters, the UIImageView is pinned to a UIView

I'm pausing like this:

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

How can I work around this?

链接地址: http://www.djcxy.com/p/74220.html

上一篇: 点击的UITextFiled被移出界面

下一篇: 当CALayer暂停并且视图旋转时,iPhone应用程序崩溃