iOS: How do I support Retina Display with CGLayer?

前端 未结 2 1583
情书的邮戳
情书的邮戳 2021-01-30 04:51

I\'m drawing a graph on a CALayer in its delegate method drawLayer:inContext:.

Now I want to support Retina Display, as the graph looks blurry on the latest

2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 05:08

    I decided not to use CGLayer and directly draw on the graphics context of the CALayer, and now it's drawn nicely in high resolution on retina display.

    I found the similar question here, and found that there is no point of using CGLayer in my case.

    I used CGLayer because of the Apple's sample program "Using Multiple CGLayer Objects to Draw a Flag" found in the Quartz 2D Programming guide. In this example, it creates one CGLayer for a star and uses it multiple times to draw 50 stars. I thought this was for a performance reason, but I didn't see any performance difference.

    For the purpose of cutting off the graph lines exceeding the edge of the layer, I decided to use multiple CALayers.

提交回复
热议问题