Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use an asset catalog image's slicing information programmatically?

I used to have an image in my project and I would load it like this:

UIImage *image = [[UIImage imageNamed:@"image_name"] resizableImageWithCapInsets:UIEdgeInsetsMake(10.0f, 10.0f, 10.0f, 10.0f)];

Now I put that image into XCode 5's new asset catalog and I set the slicing for it. How do I use that image in my code so that I don't have to explicitly call resizableImageWithCapInsets when loading the image?

Said another way, how do I take the slicing information stored in Images.xcassets and store it in a UIImage's capInsets property?

Or am I thinking about this all wrong?

like image 669
Quentin Avatar asked Jan 17 '14 20:01

Quentin


1 Answers

Ok, I was able to figure this out.

In order to automatically use the slicing information in an image stored in the asset catalog (Images.xcassets) you need to set your Deployment Target to 7.0 (or higher).

Hope this helps someone else out there.

like image 151
Quentin Avatar answered Sep 29 '22 06:09

Quentin