tags:

views:

58

answers:

2

When is it recommended to use gradient created by the iphone itself and when is an image the better choice?

A: 

That is a pretty vague question, are you thinking about any particular situations? Unless you are doing very intensive processing or heavy graphics (game) then the difference in processing time is probably not going to be noticeable. I haven't measured it, but I would bet the difference in overhead is pretty minimal, so do whichever you think is easier/nicer looking until you find a problem.

joelm
+1  A: 

This question asks something similar. As with most performance-related questions, you are best served by using Instruments and other tools to determine if this is an area worth spending the time to optimize.

As I state in my answer, I had noticed a significant amount of time being spent during launch in the Quartz functions for drawing a radial gradient in the background on an iPhone 3G. By switching to an image, I was able to noticeably reduce startup time of my application. However, a new image would need to be generated for each larger display size, so for the newer devices (iPad, iPhone 4), I use the Quartz radial gradient once again because of the negligible rendering time on those systems.

For linear gradients, it has been my experience that a CAGradientLayer gives you both good performance and scalability to new resolutions, but again you'll need to test this in your particular application.

Brad Larson
great thanks!But doesn't using gradient layer reduce memory usage?
egil
@egil - There shouldn't be much of a memory difference, because same-sized views or layers will use the same amount of memory for their content. Oddly, I noticed a slight memory footprint decrease in Memory Monitor when loading the static image vs. drawing the Quartz radial gradient. As I said, test any performance assumptions you make.
Brad Larson