CATiledLayer with animating content
I've got this UIView which is backed by a CATiledLayer. My setup works pretty smooth at the moment but the horror starts when I want to animate certain view objects on this CATiledLayer.
I've read that I can force the CATiledLayer to redraw itself by using setNeedsDisplay
. But this actually redraws everything on the screen. So all the tiles are loaded all over again.
How should I update my layer when something is animating? Let开发者_开发百科's take the following as an example: I've got 6 green rectangles on my layer and when I press a UIButton I'd like to change the color of rectangle number 4 to red and reposition rectangle 1 2 and 3 on a bezier curve.
you can use CATiledView:setNeedsDisplayInRect: to radraw only portions of the layer.
in your case you should:
- redraw 4 with new color
- redraw old positions of 1, 2 and 3 with no rectangles
- redraw new positions on 1, 2 and 3
精彩评论