Slow UIImage

Let’s say you’re working on an iPhone app. Let’s say you’ve created some UIImage’s from some .png’s in your bundle and then used -stretchableImageWithLeftCapWidth. And you’re using them with some custom controls or just customizing UIButton (because, really, that’s the only way you’re going to get decent looking buttons). Everything runs great on the simulator.

Then you try it on an actual iPhone. Wow, that’s slow as *#@!.

The problem is you created your UIImage using -imageWithContentsOfFile.

The solution is to create your UIImage using -imageNamed. You probably overlooked it. The UICatalog sample uses -imageNamed — I don’t know how I, I mean, you missed it the first time.

Leave a Reply