Beware UIImage resizableImageWithCapInsets: !!

I just spent a day trying to fix a problem I never understood, thinking a massive performance slowdown was due to the excellent PSTCollectionView class.  Nope.

In the end it was this line of code that brought my UI to a halt:


UIEdgeInsets stretchInsets = UIEdgeInsetsMake(23.9, 97.0, 9.9, 9.9);  // BAD!!! Must be int values!
normalImage = [normalImage resizableImageWithCapInsets: stretchInsets];

A word to the wise: When using UIEdgeInsets to create a resizable UIImage, BE SURE to use integer values and not floats! Otherwise some crazy interpolation takes place and the whole UI just dies.

I just saved you time. Just remember this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s