Color
public extension Color
-
Create a SwiftUI Color
myView .backgroundColor(Color(material: .blue400))Declaration
Swift
init(material color: MaterialColor, alpha: Float = 1.0)Parameters
colorThe
MaterialColoralphaThe 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) -> ColorParameters
colorThe
MaterialColoralphaThe 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 aMaterialColorDeclaration
Swift
@available(macOS 11.0, *) var asMaterialColor: MaterialColor? { get }
Color Extension Reference