Reputation: 2543
I have a UIView subclass that draws a bunch of bezier paths (typically around 10-20 of them). Currently I have a single CALayer doing all the drawing. Now I would like to be able to animate all the line widths individually. I was thinking about using a bunch of CAShapeLayers, each of them drawing just one of the bezier paths. CAShapeLayer has a lineWidth property that is animatable.
I got this idea from this post: Animating Pi Slices using a Custom CALayer.
My concern is whether this would require 10-20 times the memory for drawing, because each of the CAShapeLayers would create a separate drawing context, or if they would all draw into the same context and share memory?
Upvotes: 1
Views: 530
Reputation: 100622
They'd each have separate storage on the GPU for as long as they were in the view hierarchy and unless and until a low-memory warning occurred subsequently.
That being said, don't suffer the curse of premature optimisation. If it's the simplest, most direct way to express your animation then it should be what you do. Phones and tablets have a lot of memory nowadays.
Upvotes: 2