[CALayer display]:忽略伪图层大小(8681.000000、3508.000000)、contentsScale 3.000000、后备存储大小(26043.000000、10524.000000)

[CALayer display]: Ignoring bogus layer size (8681.000000, 3508.000000), contentsScale 3.000000, backing store size (26043.000000, 10524.000000)

我正在做的是,我有一个显示图像的图像视图,在它上面我有一个叠加视图,我可以在其中绘制注释。它在其他设备上运行良好,但在 iPhone 中未显示 12 个叠加层!尝试使用 CATiledLayer 但没有成功!我只是给出 iPhone SE & iPhone 12.

的截图

这是iPhone SE输出

这是 iPhone 12 输出:

我正在使用 UIBezierPath 绘制线条!这就是我画线的方式:

+(UIBezierPath*) pathForArrowUsingStartPoint:(CGPoint) startPoint endPoint:(CGPoint) endPoint superRect:(CGRect) superRect lineWidth:(double) LINE_WIDTH
                                   arrowSize:(double) ARROW_SIZE arrowTipSize:(double) ARROW_TIP_DIST
{
    UIBezierPath* bp = [UIBezierPath bezierPath];
    CGPoint transLatedEndPoint = [Annotation convertBetweenUIViewCoordAndXYCoord:endPoint inRect:superRect];
    CGPoint transLatedStartPoint = [Annotation convertBetweenUIViewCoordAndXYCoord:startPoint inRect:superRect];
    CGFloat lineAngle = [Annotation angleBetweenPoint1:transLatedStartPoint Point2:transLatedEndPoint];
    
    //calculate the rect to draw
    
    CGPoint p0 ;
    p0.x = transLatedEndPoint.x + LINE_WIDTH * cosf(lineAngle + M_PI/2);
    p0.y = transLatedEndPoint.y + LINE_WIDTH * sinf(lineAngle + M_PI/2);
    
    p0 = [Annotation convertBetweenUIViewCoordAndXYCoord:p0 inRect:superRect];
    
    CGPoint p1;
    p1.x = transLatedEndPoint.x + LINE_WIDTH * cosf(lineAngle - M_PI/2);
    p1.y = transLatedEndPoint.y + LINE_WIDTH * sinf(lineAngle - M_PI/2);
    
    p1 = [Annotation convertBetweenUIViewCoordAndXYCoord:p1 inRect:superRect];
    
    CGPoint p2 ;
    p2.x = transLatedStartPoint.x - LINE_WIDTH * cosf(lineAngle + M_PI/2);
    p2.y = transLatedStartPoint.y - LINE_WIDTH * sinf(lineAngle + M_PI/2);
    
    p2 = [Annotation convertBetweenUIViewCoordAndXYCoord:p2 inRect:superRect];
    
    CGPoint p3;
    p3.x = transLatedStartPoint.x - LINE_WIDTH * cosf(lineAngle - M_PI/2);
    p3.y = transLatedStartPoint.y - LINE_WIDTH * sinf(lineAngle - M_PI/2);
    
    p3 = [Annotation convertBetweenUIViewCoordAndXYCoord:p3 inRect:superRect];
    
    // now drawing arrow head using triangle
    
    CGPoint arrow0P0;
    arrow0P0.x = transLatedEndPoint.x - ARROW_SIZE * cosf(lineAngle - M_PI/4);
    arrow0P0.y = transLatedEndPoint.y - ARROW_SIZE * sinf(lineAngle - M_PI/4);
    
    arrow0P0 = [Annotation convertBetweenUIViewCoordAndXYCoord:arrow0P0 inRect:superRect];
    
    CGPoint arrow0P1;
    arrow0P1.x = transLatedEndPoint.x - ARROW_SIZE * cosf(lineAngle + M_PI/4);
    arrow0P1.y = transLatedEndPoint.y - ARROW_SIZE * sinf(lineAngle + M_PI/4);
    
    arrow0P1 = [Annotation convertBetweenUIViewCoordAndXYCoord:arrow0P1 inRect:superRect];
    
    CGPoint arrow0Tip;
    arrow0Tip.x = transLatedEndPoint.x + ARROW_TIP_DIST * cosf(lineAngle);
    arrow0Tip.y = transLatedEndPoint.y + ARROW_TIP_DIST * sinf(lineAngle);
    arrow0Tip = [Annotation convertBetweenUIViewCoordAndXYCoord:arrow0Tip inRect:superRect];
    
    [bp moveToPoint:p0];
    [bp addLineToPoint:p1];
    [bp addLineToPoint:p2];
    [bp addLineToPoint:p3];
    [bp closePath];
    //arrows
    
    [bp moveToPoint:arrow0P0];
    [bp addLineToPoint:arrow0Tip];
    [bp addLineToPoint:arrow0P1];
    [bp addLineToPoint:arrow0P0];
    
    [bp closePath];
    return bp;
    
}

真的只是评论,放在这里是为了便于格式化。你应该在某处有某种缩放比例,比如 属性

@property (nonatomic) CGFloat zoom;

然后在scrollview缩放的时候设置,比如

- (void) scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
    [self setZoom:scale * self.zoom inScrollView:scrollView];
}

然后在 setZoom 中应用您的限制。 YMMV。当遇到类似问题时,这对我有用。

较新的设备的比例因子为 3。对于大图像,canvas 这么大会引发错误,而我的 canvas 不可见。只需更改绘图的比例因子 canvas 即可。

self.drawingCanvas.contentScaleFactor = 2.0;