Antonio MG
Antonio MG

Reputation: 20410

How to use images sliced with the slicing tool of the XCode5 assets catalog

In the assets catalog in the new XCode5 there's a tool to slice your images, I assume this is used for images that are going to be stretched, and it has the same effect as using the resizableImageWithCapInsets: method on a UIImage object.

My question is, once I sliced my image, how do I use it in my code? I just create the image with the size I want and it's stretched automatically using the insents I set in the slicing tool? Or I have to create it using a special way?

I haven't found any documentation about it yet.

Upvotes: 8

Views: 5184

Answers (1)

Fogmeister
Fogmeister

Reputation: 77651

The image slicing in Xcode 5 works with [UIImage imageNamed:@"blah"];. You don't have to do anything in the code. The slicing information is automagically contained in the UIImage that gets returned.

You can set everything using the asset catalog: retina, iPad, slicing, etc...

Then give the whole set of images a name and just use that name.

Your app will then pull out the correct image from the catalog including all the slicing information.

Upvotes: 14

Related Questions