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.
Step 1: Open a sample image in Photoshop as shown below: Step 2: Now select the slice tool from the tool palette. Step 3: Now create a slice of the image from where you want. After drawing the slice, you will see that Photoshop automatically draws other slices to match the whole document.
Although the Slice Tool is a cutting tool mainly used for web design. If you’re thinking about cutting out shapes or creating a sliced text effect, the Slice Tool isn’t what you’re looking for. I mean, technically you can, but there are better tools.
There are several aligned options for two or more selected slices. Now, a question may arise that how to select multiple slices? The answer is that we can select multiple layers using the slice select tool using by holding the SHIFT key.
Now a question may arise how to differentiate whether it is auto slice or user slice? The answer is that auto slices do not have a scaling option enabled within them, but a user slice can be scaled using the slice select tool.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With