Color

public extension Color
  • Create a SwiftUI Color

    myView
        .backgroundColor(Color(material: .blue400))
    

    Declaration

    Swift

    init(material color: MaterialColor,
         alpha: Float = 1.0)

    Parameters

    color
    alpha

    The alpha value of the color. Optional.

    Return Value

    The SwiftUI Color

  • Create a SwiftUI Color

    myView
        .backgroundColor(.material(.blue400))
    

    Declaration

    Swift

    static func material(_ color: MaterialColor,
                         alpha: Float = 1.0) -> Color

    Parameters

    color
    alpha

    The alpha value of the color. Optional.

    Return Value

    The SwiftUI Color

  • The color as a MaterialColor, or nil if the color cannot be represented as a MaterialColor

    Declaration

    Swift

    @available(macOS 11.0, *)
    var asMaterialColor: MaterialColor? { get }