仅适用于iPhone 5s和之前的版本:由于未捕获的异常'CALayerInvalidGeometry'而终止应用,原因:'CALayer位置包含NaN:[50 nan]'

时间:2016-09-10 09:29:07

标签: ios iphone calayer

崩溃发生在iPhone 5s(真实设备,模拟器中应用程序不会崩溃)和以前的型号。

代码崩溃了。

private lazy var progressViewMaskLayer: CAShapeLayer = {
    let progressViewMaskLayer = CAShapeLayer()
    progressViewMaskLayer.path = UIBezierPath(rect: CGRect(x: 0.0, y: 0.0, width: self.bounds.width - 8, height: self.bounds.width - 8)).CGPath
    return progressViewMaskLayer
}()

private func setProgressViewHeight(height: CGFloat) {
    let size = progressViewMaskLayer.frame.size
    let origin = progressViewMaskLayer.frame.origin
    progressViewMaskLayer.frame.size = CGSize(width: size.width, height: height) // CRASH HERE!
    progressViewMaskLayer.frame.origin = CGPoint(x: origin.x, y: 64.0 - height)
}

*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [0 nan]'

0 个答案:

没有答案