init(named:in:variableValue:configuration:)
Creates an image by using the name, configuration, and variable value you specify.
Declaration
convenience init?(named name: String, in bundle: Bundle? = nil, variableValue: Double, configuration: UIImage.Configuration? = nil)Parameters
- name:
The name of the image asset or file.
- bundle:
The bundle that contains the image file or asset catalog.
- variableValue:
The value the system uses to customize the image content, between
0and1. - configuration:
The image configuration the system applies to the image.
Return Value
An object that contains the image variant that matches the configuration data; otherwise, nil if the system didn’t find a suitable image.
Discussion
When searching the asset catalog, this method prefers an asset containing a symbol image over an asset with the same name containing a bitmap image. Because the system supports symbol images in iOS 13 or later, you may include both types of assets in the same asset catalog. In iOS 12 or earlier, the system automatically chooses the bitmap image.
You can’t use this method to load system symbol images; use the init(systemName:variableValue:configuration:) method instead.
This method checks the system caches for an image object with the name you specify, and returns the variant of that image that best matches the trait collection you specify. If a matching image object isn’t in the cache, this method creates the image from an available asset catalog or loads the image from disk.
The system may purge cached image data at any time to free up memory. Purging occurs only for unused images that are in the cache.
See Also
Loading and caching images
Providing images for different appearancesConfiguring and displaying symbol images in your UICreating custom symbol images for your appinit(named:in:compatibleWith:)init(named:in:with:)init(named:)init(imageLiteralResourceName:)init(systemName:withConfiguration:)init(systemName:variableValue:configuration:)init(systemName:compatibleWith:)init(systemName:)init(resource:)Building high-performance lists and collection views