<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIImageAsset",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIImageAsset"
  },
  "title" : "UIImageAsset"
}
-->

# UIImageAsset

A container for a collection of images that represent multiple ways of describing a single piece of artwork.

```
class UIImageAsset
```

## Overview

A common use case for [`UIImageAsset`](/documentation/UIKit/UIImageAsset) is the grouping of multiple images of the same item at different display scales. Image asset objects aren’t assigned to instances of [`UIImage`](/documentation/UIKit/UIImage) rather; [`UIImage`](/documentation/UIKit/UIImage) provides an asset when multiple representations of an image are available. Images retrieved from image asset catalogs using the [`init(named:)`](/documentation/UIKit/UIImage/init(named:)) or [`init(named:in:compatibleWith:)`](/documentation/UIKit/UIImage/init(named:in:compatibleWith:)) methods automatically have an image asset object that allows access to other images from the catalog.

### Register an image

When you register an image with an image asset, you associate a [`UITraitCollection`](/documentation/UIKit/UITraitCollection) object with the image. The trait collection must contain the [`displayScale`](/documentation/UIKit/UITraitCollection/displayScale) and [`userInterfaceIdiom`](/documentation/UIKit/UITraitCollection/userInterfaceIdiom) trait properties. If you don’t define these traits in the trait collection, the following defaults are assigned:

- [`displayScale`](/documentation/UIKit/UITraitCollection/displayScale) = `1.0`
- [`userInterfaceIdiom`](/documentation/UIKit/UITraitCollection/userInterfaceIdiom) = [`UIUserInterfaceIdiom.unspecified`](/documentation/UIKit/UIUserInterfaceIdiom/unspecified)

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.

### Retrieve 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 [`displayScale`](/documentation/UIKit/UITraitCollection/displayScale) and [`userInterfaceIdiom`](/documentation/UIKit/UITraitCollection/userInterfaceIdiom) traits. If these traits aren’t defined in the trait collection, the following defaults are assigned:

- [`displayScale`](/documentation/UIKit/UITraitCollection/displayScale) = scale of the current device
- [`userInterfaceIdiom`](/documentation/UIKit/UITraitCollection/userInterfaceIdiom) = 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 `UIImageAsset` for an image.

[`UIImageView`](/documentation/UIKit/UIImageView) automatically retrieves the correct image when [`traitCollectionDidChange(_:)`](/documentation/UIKit/UITraitEnvironment/traitCollectionDidChange(_:)) is called on it.

## Topics

### Initializing an image asset

[`-  init`](/documentation/UIKit/UIImageAsset/init())

Creates a new image asset object.

[`-  initWithCoder:`](/documentation/UIKit/UIImageAsset/init(coder:))

Creates an image asset from data in an unarchiver.

### Registering and unregistering images

[`-  registerImage:withTraitCollection:`](/documentation/UIKit/UIImageAsset/register(_:with:)-2plm5)

Registers an image with the specified trait collection.

[`-  registerImage:withConfiguration:`](/documentation/UIKit/UIImageAsset/register(_:with:)-89c5b)

Registers an image with the specified image configuration details.

[`-  unregisterImageWithTraitCollection:`](/documentation/UIKit/UIImageAsset/unregister(imageWith:))

Unregisters the image with the specified trait collection from the image asset.

[`-  unregisterImageWithConfiguration:`](/documentation/UIKit/UIImageAsset/unregisterImage(with:))

Unregisters the image with the specified image configuration details from the image asset.

### Retrieving an image from an image asset

[`-  imageWithTraitCollection:`](/documentation/UIKit/UIImageAsset/image(with:)-3dsgf)

Retrieves the variant of the image that best matches the specified trait collection.

[`-  imageWithConfiguration:`](/documentation/UIKit/UIImageAsset/image(with:)-8jdwv)

Retrieves the variant of the image that best matches the specified image configuration details.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)