Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATiledLayer: How to cause reload of just some tiles?

I'm using a tiled layer in a scroll view to display a custom view. The contents of the custom view change periodically, and I know the rectangle in which those changes occur. However I have found that if I do a setNeedsRedisplay only one tile is getting redrawn. How can I tell the CATiledLayer to redraw only the affected tiles?

like image 704
Frank E Avatar asked Oct 21 '25 03:10

Frank E


1 Answers

If you call setNeedsDisplay on the CATiledLayer, then it redraws all its tiles. If you use setNeedsDisplayInRect instead, it should only redraws those tiles that intersect with the rectangle you specify. Note however, that it will redraw the whole tile, not just the part that intersects with the rectangle.

Note also the redraw bug in CATiledLayer when you call setNeedsDisplay when it is in the process of drawing. More on that you can find in this question.

like image 128
fishinear Avatar answered Oct 23 '25 18:10

fishinear



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!