Graphics Reference
In-Depth Information
}
@end
We've used some tricks here that are worth explaining:
The tileSize property of CATiledLayer is measured in pixels, not points, so to
ensure that the tile exactly matches the size of the cell, we've multiplied the size by
the screen scale.
In the -drawLayer:inContext: method, we need to know which indexPath the layer
relates to so that we can load the correct image. We've taken advantage of the feature
of CALayer that allows us to store and retrieve arbitrary values using KVC, and tagged
each layer with the correct image index.
Despite our concerns, it turns out that CATiledLayer works very well in this case; the
performance problems are gone, and the amount of code needed is comparable to the GCD
approach. The only slight issue is that there is a notable fade-in as each image appears
onscreen after loading (see Figure 14.4).
Figure 14.4 The images fading in as they are loaded
We can adjust the speed of the fade-in using the CATiledLayer fadeDuration property, or
even remove the fade altogether, but it doesn't address the real issue: There will always be
a delay between when the image begins loading and when it is ready to draw, and that will
Search WWH ::




Custom Search