SystemImage

public protocol SystemImage : RawRepresentable where Self.RawValue == String

Any string corresponding to a system image (SF Symbols).

All properties and functions have default implementations. At a minimum just have your string-based enum conform to SystemImage. The raw value of the enum should match a sytem image name (e.g. checkmark.seal).

  • fallbackImage Default implementation

    Fallback image to use in case a system image cannot be loaded.

    Default Implementation

    Returns a 16 x 16 square filled with .systemPink.

    Declaration

    Swift

    static var fallbackImage: UIImage { get }
  • image Default implementation

    A system image for this name value.

    Default Implementation

    Returns loadImage() nil-coalesced to fallbackImage.

    Declaration

    Swift

    var image: UIImage { get }
  • textStyle Default implementation

    Image will scale according to the specified text style.

    Return nil to not have the system image scale (not recommended).

    Default Implementation

    Returns .body text style.

    Declaration

    Swift

    static var textStyle: UIFont.TextStyle? { get }
  • configuration Default implementation

    Image configuration to be used to load the system image.

    Default Implementation

    Returns UIImage.SymbolConfiguration(textStyle:) passing in the specified textStyle or else returns nil if textStyle is nil.

    Declaration

    Swift

    static var configuration: UIImage.Configuration? { get }
  • renderingMode Default implementation

    Rendering mode to use for the system image.

    Default Implementation

    Returns .automatic rendering mode.

    Declaration

    Swift

    static var renderingMode: UIImage.RenderingMode { get }
  • loadImage() Default implementation

    Loads the named system image.

    Default Implementation

    Returns UIImage(systemName:) passing in the associated rawValue and configuration and combined with the specified renderingMode.

    Declaration

    Swift

    func loadImage() -> UIImage?

    Return Value

    The named system image or else nil if the system image cannot be loaded.