iOS:CGContextStrokePath(context)在iOS 12中使用EXC_BAD_ACCESS崩溃

时间:2019-01-03 12:52:40

标签: ios objective-c ios12 catiledlayer

我正在尝试使用CALayerCGContextStrokePath(context)来绘制签名,但是它仅在iOS 12中因以下错误而棘手崩溃:

  

malloc:已释放对象0x1196538c8的校验和不正确:可能   释放后修改。       损坏的值:0x4069e00000000000       (899,0x17190b000)malloc:***在malloc_error_break中设置一个断点进行调试

代码段:

- (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)contx {
    if (layer == canvasLayer) {
        //we don't want this to fire after the background layer update
        //and after the path has been released
        if (!touching) return;
        CGContextAddPath(contx, path);
        CGContextSetLineWidth(contx, 7.0f);
        CGContextStrokePath(contx);
    }
    else if (layer == bckLayer) {
        CGContextSaveGState(contx);
        CGContextTranslateCTM(contx, 0, backgroundLayer.bounds.size.height);
        CGContextScaleCTM(contx, 1.0, -1.0);
        CGImageRef ref = cacheImage.CGImage;
        CGContextDrawImage(contx, backgroundLayer.bounds, ref);
        CGContextRestoreGState(ctx);
    }
}

0 个答案:

没有答案