iOS Dev Nugget 101 Asset Catalog


Need to run a code review on your codebase? Hire me

In a nutshell, Asset Catalogs lets you manage image assets — app icons, launch images and image — you use in your app.

There isn't anything that you absolutely need to use Asset Catalogs for. But there's a few advantages to using Asset Catalogs:

  1. By grouping image assets into image sets, it is slightly easier to navigate your images.
  2. Image assets now support vector PDFs. You create a PDF — with dimensions suitable for 1x — and drop it into a image set, say, saveButton. i.e., you don't have to specify @2x or @3x versions in that image set. During build time, Xcode will automatically generate 1x, 2x and 3x images — i.e. the equivalent of saveButton.png, saveButton@2x.png and saveButton@3x.png automatically. You only need to write [UIImage imageNamed:@"saveButton"], and it will automatically pick up the right version. Note that Xcode generate static versions of the files during build time, so you can't expect to stretch the images in your code and expect it to still have high resolution. (It's different for OS X though, the vector version is actually preserved).
  3. The slice tool (In Xcode, click on an image set in an asset catalog and choose Editor > Show Slicing) is very useful for specifying how you slice an image. Your designer can create full sized versions of an image and you can specify the cap inset in Xcode.

If you haven't been using Asset Catalogs, now is a good time to start.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues