Performance when frequently drawing CGPaths

后端 未结 5 1497
無奈伤痛
無奈伤痛 2021-02-01 08:16

I am working on an iOS App that visualizes data as a line-graph. The graph is drawn as a CGPath in a fullscreen custom UIView and contains at most 320

5条回答
  •  被撕碎了的回忆
    2021-02-01 08:46

    Depending on how you make your path, it may be that drawing 300 separate paths is faster than one path with 300 points. The reason for this is that often the drawing algorithm will be looking to figure out overlapping lines and how to make the intersections look 'perfect' - when perhaps you only want the lines to opaquely overlap each other. Many overlap and intersection algorithms are N**2 or so in complexity, so the speed of drawing scales with the square of the number of points in one path.

    It depends on the exact options (some of them default) that you use. You need to try it.

提交回复
热议问题