Class

UIImage.Configuration

A configuration object containing the traits that the system used when selecting the current image variant.

Declaration

class Configuration : NSObject

Overview

Images may contain multiple variants to account for environmental factors, such as whether the interface is light or dark. The image configuration object lets you override the current environment and render an image with specific attributes. For example, you might want to render a specific version of your image to your interface.

UIImage.Configuration objects are immutable and you don't create them directly. Instead, get an existing image configuration object from a UITraitCollection or UIImage object. To add attributes to your configuration object, use the applying(_:) method to create a new object that merges the existing object's values with new values you supply. Assign the new object to the preferredSymbolConfiguration property of the UIImageView object you use to display the image. If you draw the image directly, use the withConfiguration(_:) method to create a new image that contains the new attributes.

Topics

Modifying a Configuration Object

func applying(UIImage.Configuration?) -> Self

Returns a configuration object that applies the specified configuration values on top of the current object's values.

func withTraitCollection(UITraitCollection?) -> Self

Returns a new configuration object that merges the current traits with the traits from the specified trait collection.

Getting the Configuration Traits

var traitCollection: UITraitCollection?

The traits associated with the image configuration.

Relationships

Inherits From

See Also

Changing the Image Attributes

func withConfiguration(UIImage.Configuration) -> UIImage

Returns a new version of the current image, replacing the current configuration attributes with the specified attributes.

func applyingSymbolConfiguration(UIImage.SymbolConfiguration) -> UIImage?

Returns a new version of the current image, applying the specified configuration attributes on top of the current attributes.

func imageFlippedForRightToLeftLayoutDirection() -> UIImage

Returns a new version of the current image, prepared to flip horizontally when it’s in a right-to-left layout.

func withHorizontallyFlippedOrientation() -> UIImage

Returns a new version of the image whose orientation is the mirror of the original image.

func withRenderingMode(UIImage.RenderingMode) -> UIImage

Returns a new version of the image configured with the specified rendering mode.

func withAlignmentRectInsets(UIEdgeInsets) -> UIImage

Returns a new version of the image that uses the specified alignment insets.

func resizableImage(withCapInsets: UIEdgeInsets) -> UIImage

Returns a new version of the image that contains the specified cap insets.

func resizableImage(withCapInsets: UIEdgeInsets, resizingMode: UIImage.ResizingMode) -> UIImage

Returns a new version of the image with the specified cap insets and options.

func imageWithoutBaseline() -> UIImage

Creates a copy of the current image object without any baseline information.

func withBaselineOffset(fromBottom: CGFloat) -> UIImage

Creates a new image with a baseline located at the specified offset from the bottom of the image.

class UIImage.SymbolConfiguration

An object containing the specific font, size, style, and weight attributes to apply to a symbol image.