1

我正在尝试使用CALayerwith绘制签名,CGContextStrokePath(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);
    }
}
4

0 回答 0