如何使用XCode5资产目录的切片工具切片的图像

时间:2022-02-27 20:00:09

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.

在新XCode5的资产目录中,有一个切片图像的工具,我假设它用于将要拉伸的图像,它与在UIImage对象上使用resizableImageWithCapInsets:方法具有相同的效果。

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.

我还没有找到任何关于它的文档。

1 个解决方案

#1


14  

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.

Xcode 5中的图像切片与[UIImage imageNamed:@“blah”];一起使用。您无需在代码中执行任何操作。切片信息自动包含在返回的UIImage中。

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

您可以使用资产目录设置所有内容:视网膜,iPad,切片等...

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.

然后,您的应用程序将从目录中提取包含所有切片信息的正确图像。

#1


14  

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.

Xcode 5中的图像切片与[UIImage imageNamed:@“blah”];一起使用。您无需在代码中执行任何操作。切片信息自动包含在返回的UIImage中。

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

您可以使用资产目录设置所有内容:视网膜,iPad,切片等...

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.

然后,您的应用程序将从目录中提取包含所有切片信息的正确图像。