LinearGradient

A linear gradient.

StructureiOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+LinearGradient in SwiftUI

Declaration

React
type LinearGradient =
  | { colors: Color[]; startPoint: UnitPoint; endPoint: UnitPoint; }
  | { gradient: Gradient; startPoint: UnitPoint; endPoint: UnitPoint; }
  | { stops: GradientStop[]; startPoint: UnitPoint; endPoint: UnitPoint; };
Swift
@frozen nonisolated struct LinearGradient

Overview

The gradient applies the color function along an axis, as defined by its start and end points. The gradient maps the unit space points into the bounding rectangle of each shape filled with the gradient.

When using a linear gradient as a shape style, you can also use ShapeStyle.linearGradient(_:startPoint:endPoint:).

From Apple’s SwiftUI documentation. Code samples there are Swift.

See also

More in Drawing and shapes.