Returns the named image that is also compatible with the specified trait collection.
- iOS 8.0+
- tvOS 9.0+
The name of the image. For images in asset catalogs, specify the name of the image asset. For PNG image files, specify the filename without the filename extension. For all other image file formats, include the filename extension in the name.
The bundle containing the image file or asset catalog. Specify
nilto search the app’s main bundle.
The traits associated with the intended environment for the image. Use this parameter to ensure that the correct variant of the image is loaded. If you specify
nil, this method uses the traits associated with the main screen.
The image object that best matches the desired traits with the given name, or
nil if no suitable image was found.
This method looks in the system caches for an image object with the specified name and returns the variant of that image that best matches the specified trait collection. If a matching image object is not already in the cache, this method locates and loads the image data from disk or from an available asset catalog, and then returns the resulting object.
The system may purge cached image data at any time to free up memory. Purging occurs only for images that are in the cache but are not currently being used.
In iOS 9 and later, this method is thread safe.