Sunday, July 19, 2015

iOS Asset Catalogs - just an overview

Asset catalogs are to simply the management of images that are used by the app as part of its user interface. 

Typically, an asset catalog can include 

Image sets: Used for most type of images, an image set contains all versions or representations of an image that are necessary to support various devices and scale factors. 

App Icons : App icon contains all representations of an icon that iOS must provide to be displayed on device’s homescreen and in the app store. 

Launch Images: Launch image sets contain all the representations of the static launch image that iOS apps must provide to temporarily.

There are 3 areas of Asset catalog in Xcode, set list, set viewer, set attributes inspector. 

To access the image, the platform specific methods such as imageNamed: can be used. 

In Xcode 6, if the deployment target minimum is 7.0, then below two features are extra 

1. Individual image can be loaded using set names
2. For deployment targets of at least 7.0 or OX 10.9, Xcode compiles the asset catalog to a runtime binary file format that reduces the download time of the app. 

Each asset catalog in Xcode has a corresponding folder with an .xcassets extension, and there are sub folders for each set. Each folder in turn contains the image representations, along with the Contents.json file describing each image. This file is automatically created by Xcode. 

We can share the asset catalog between different projects in the same workspace. 

It is very easy to create an image set. Just drag and drop the image to be added to the set and by default it takes it as the 1x resource. 

To customize image set for size classes, In the attribute inspector, select the Height and width and select Any & Regular. This adds many combinations such as one for e.g. 2x[-*] is a 2x image for horizontal compact size class and any vertical size class. 


Note also that In the device, we can specific if separate image is needed depending on the device models. To do this, on the Devices drop down, select the option Device Specific. 


references:

No comments:

Post a Comment