`UIGraphicsImageRenderer` + `drawHierarchy` gives very flat colors

My setup:

  • a UILabel with text in it
  • and then
let aBugRenderer = UIGraphicsImageRenderer(size: aBugLabel.bounds.size)
let aBugImage = aBugRenderer.image { context in
    aBugLabel.drawHierarchy(in: aBugLabel.bounds, afterScreenUpdates: true)
}

The layout and everything is correct, the image is correct, but I used my colors in the displayP3 color space to configure the source UILabel.textColor

And unfortunately, the resulted image ends up being sRGB IEC61966-2.1 color space and the color appears way bleaker than when it's drawn natively.

Question: how can I set up the renderer so that it draws the same color.

`UIGraphicsImageRenderer` + `drawHierarchy` gives very flat colors
 
 
Q