A container for a collection of images that represent multiple ways of describing a single piece of artwork.
- iOS 8.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
A common use case for
UIImage is the grouping of multiple images of the same item at different display scales. Image asset objects are not assigned to instances of
UIImage provides an asset when multiple representations of an image are available. Images retrieved from image asset catalogs using the
image methods automatically have an image asset object that allows access to other images from the catalog.
Registering an Image
When you register an image with an image asset, you associate a
UITrait object with the image. The trait collection must contain the
user trait properties. If you do not define these traits in the trait collection, the following defaults are assigned:
For example, if you create a trait collection that only contains a horizontal size class, the default display scale and idiom are added when the image is registered.
Retrieving an Image
When you retrieve or unregister an image from an image asset, you do so using the trait collection that was used to register the image. To ensure the correct image is retrieved, the trait collection used must contain the
user traits. If these traits are not defined in the trait collection, the following defaults are assigned:
display= scale of the current device.
user= the type of interface used on the current device.
For example, if you create a trait collection that only contains a horizontal size class, the default display scale and idiom of the current device are added when searching the
UIImage for an image.