Contents

radialGradient(_:center:startRadius:endRadius:)

A radial gradient.

Declaration

static func radialGradient(_ gradient: AnyGradient, center: UnitPoint = .center, startRadius: CGFloat = 0, endRadius: CGFloat) -> some ShapeStyle

Discussion

The gradient applies the color function as the distance from a center point, scaled to fit within the defined start and end radii. The gradient maps the unit space center point into the bounding rectangle of each shape filled with the gradient.

For example, a radial gradient used as a background:

ContentView()
    .background(.radialGradient(.red.gradient, endRadius: 100))

For information about how to use shape styles, see ShapeStyle.

See Also

Radial gradients