iosobjective-ccore-graphicsuibezierpathiphone12

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


What I am doing is, I've an imageview that displays an image and above it I've a overlay view where I draw the annotations. It's working fine on other devices but in iPhone 12 overlays is not displayed!Tried using CATiledLayer with no luck! I am just giving the screenshot of iPhone SE & iPhone 12.

This is iPhone SE output

enter image description here

And this is iPhone 12 output:

enter image description here

I am using UIBezierPath to draw the lines! This is how I am drawing the lines:

+(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;
    
}

Solution

  • Newer device has scale factor of 3. For large image a canvas that big was throwing the error and my canvas was not visible. Just changing the scale factor of my drawing canvas does the trick.

    self.drawingCanvas.contentScaleFactor = 2.0;