View Source ColorView
<ColorView>
A rectangle with a particular fill color.
Overview
Color’s appearance is equivalent to a Rectangle
with a fill-color
.
Create a color with red
, green
, blue
, and opacity
components.
<Color red={1} green={0} blue={0.5} />
A color can also be created by its name
. Named colors can be declared in the app’s asset catalog.
<Color name="MyAppColor" opacity={0.5} />
The name
attribute can also be used to create a system color or a CSS hex color.
<Color name="system-red" />
<Color name="#ff0000" />
See init(fromNamedOrCSSHex:)
for more details.
Attributes
SwiftUI Documentation
See SwiftUI.ColorView
for more details on this View.
References
The blue channel of the color, in the range 0
to 1
.
colorSpace
The color space this color is in.
Discussion
Possible values:
sRGB
sRGBLinear
displayP3
green
The green channel of the color, in the range 0
to 1
.
A named color in the project’s asset catalog, system color, or CSS hex color.
opacity
The alpha channel of the color, in the range 0
to 1
.
The red channel of the color, in the range 0
to 1
.