Question

I have been experimenting with drawing maps. I drew a map of the United States as a series of UIBezierPath's (one path for each state - converted an SVG file with PaintCode). At the same time I was working with CAShapeLayer's and was amazed at how fast they were. I decided to convert the UIBezierPath to a CAShapeLayer. It ended up being extremely slow. The view would stutter even when I rotated the device. Does anyone know why it would be so slow? It seems that whenever I fill a view with too many CAShapeLayer's it slows the application down tremendously.

This is not a code specific problem, I am just wondering if there are limitations to the amount of CALayer's you can use in an application.

Was it helpful?

Solution

The CAShapeLayer is mostly used to create shapes that you would animate. So when you use it each modification is animated. I don't know UIBezierPath but CAShapeLayer also use antialiasing during rasterization and that would require offscreen rendering that is an expensive task.

OTHER TIPS

offscreen rendering includes shouldRasterize(光栅化) masks(遮罩) shadows(阴影) edge antialiasing(抗锯齿) group opacity(不透明) so if you turn off opaque&shadows and turn on rasterise it will be quicker.you will feel the difference. but still slow the application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top