0

I was looking up methods of altering the background view of a table view cell.

My initial reaction was to create an image with rounded corners, create a stretchable image from it, and set this as the cells background view when I create the cell. This seems to work pretty well in my experiments.

I also found this: How to customize the background/border colors of a grouped table view cell? This work pretty well too.

Are there performance advantages to one method over the other?

Community
  • 1
  • 1
Megasaur
  • 626
  • 8
  • 20

1 Answers1

0

Creating a stretchable image will allow the OS to optimize by stretching the image using the graphics chip*. Drawing it in code will stretch it in the CPU. The former is more efficient.

* This depends on how the image is used, and is an implementation detail. The key word here is "allows".

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • Can you give an example of when the GPU may not kick in? Or how to ensure that it will be used? – Megasaur Mar 03 '11 at 05:06
  • If you draw the image using any of the methods on UIImage, it won't leverage the GPU. But if you assign it as the image for a UIImageView, then it is likely that it will. – Lily Ballard Mar 03 '11 at 05:47
  • Thanks. I also found this: http://stackoverflow.com/questions/3838725/what-is-the-difference-between-uiimageview-and-drawinrect – Megasaur Mar 03 '11 at 06:21