简体   繁体   中英

Xcode 6 asset catalog automatically create images for smaller scales

With the need of 3x images in iOS 8 I figured it would be easier to manage images with an asset catalog in Xcode 6. I am trying to just provide a single image, the 3x scaled image to the asset catalog and I want Xcode to automatically downscale that image to generate 2x and 1x versions of the 3x image, so that I don't have to do it manually.

Right now this is what I have:

I really hope that Xcode has such a feature to automatically create 2x and 1x images and I just have not discovered it yet. If there isn't any such feature, are there any alternatives? (I know IconKit but it is annoying and hasn't been updated to support 3x images. If it was made properly in the first place it wouldn't even need an update..)

I know that Xcode automatically can generate all images from a vector pdf, but thats not what I am looking for!

I ended up making a small mac app that takes care of the dirty work. You can drag and drop one or multiple .jpg or .png files into the app's main view; it will detect the input image's scale and create the smaller scaled images. With this app I only need to create a single, 3x image and drag it into the app to create the two smaller images. It saves so much work!

The source can be found on my GitHub page, simply download it and run it on your mac! https://github.com/JonasGessner/ImageReducer

There is another way to solve this problem.

Use Automator to create Mac OS X service which create @3x, @2x and normal image on base of 1 image in @3x resolution automatically. It use just 3 methods: duplicate images, scale down, and rename.

Ready Mac OS X service made in Automator you can find here:

https://github.com/lukszar/iOS-Images-Prepare

late to the party but there is one tool which make all assets @1x, @2x, @3x and icons for you in just one click. And also export to XCAssets file.

You can find it here: https://github.com/angelvasa/AVXCAssets-Generator

在此处输入图片说明

Hope this will help someone

If you do not provide 1x or 2x assets, and your app is run on a 1x or 2x device, it should downsample the 3x asset at runtime. This may look fine, but depending on the scaling method used, it may also look really bad, so make sure this is really what you want.

If a folder named *.imageset , and the contents in it is well organized, Xcode will actually recognize them as an image. So this is another way to do this: https://github.com/albert-zhang/gen_xcassets

This python script will quickly auto generate @2x version for all images in a folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM