I wrote an application for testing image performance on iOS. I tried 3 different views, all displayed the same large PNG. The first is a view that draws using CGContextDrawImage (). The second set is self.layer.content. The third is a simple UIImageView.
The image used is created using - [UIImage initWithContentsOfData:] and cached in viewController. Each test repeatedly selects a view, adds it to the view hierarchy, and then deletes it and releases it. Loading periods are executed from the beginning of loadView in viewDidAppear and are set as fps (efficiently, viewing pictures per second).
Here are the results from iPad 1 running on 5.1 using a 912 x 634 unscaled image:
CGContext: 11 fps CALayer: 10 fps UIImageView: 430 fps (!)
Am I hallucinating? It seems almost impossible that a UIImageView can draw it quickly, but I can really see how the images flicker. I tried to exchange between two similar views in order to defeat possible caching, but the frame rate was even higher.
I always assumed that UIImageView was just a wrapper for - [CALayer setContent]. However, profiling UIImageView hardly spends time on any drawing method that I can identify.
I would like to understand what is happening. Any help would be most appreciated.
ios core-graphics core-animation calayer uiimageview
John graziano
source share