GradientType
public enum GradientType
Defines the different type of supported gradients.
-
Defines a linear gradient type, along the specified direction. When used with
GradientView
,direction
is scaled to the bounds of the view.Examples
.linear(direction: CGPoint(x: 0.0, y: 1.0)
: Define a gradient going from the left edge to the right edge..linear(direction: CGPoint(x: 1.0, y: 1.0)
: Define a gradient going from the top-left corner to the bottom-right corner..linear(direction: CGPoint(x: -1.0, y: -1.0)
: Define a gradient going from the bottom-right corner to the top-left corner..linear(direction: CGPoint(x: -1.0, y: 0.0)
: Define a gradient going from the bottom edge to the top edge..linear(direction: CGPoint(x: 0.0, y: 0.5)
: Define a gradient going from the top edge to the middle, extending the last color until the bottom edge.Note
If
direction
is.zero
, only theendColor
of theDefinition
will be drawn. SeeGradientView.Definition.endColor
for more info about what this property refers to.Declaration
Swift
case linear(direction: CGPoint)
-
Defines a radial gradient type, starting at the specified center with the given initial radius, and expanding/reducing to the specified center and final radius. When used with
GradientView
,startCenter
andendCenter
is scaled to the bounds of the view.startRadius
andendRadius
are not scaled.Examples
.radial(startCenter: CGPoint(x: 0.5, y: 0.5), startRadius: 10.0, endCenter: CGPoint(x: 0.5, y: 0.5), endRadius: 200.0)
: Define a radial gradient that starts in the center of the view with an initial radius of 10, and expands to a radius of 200 without changing its center..radial(startCenter: CGPoint(x: 0.0, y: 0.5), startRadius: 200.0, endCenter: CGPoint(x: 1.0, y: 0.5), endRadius: 10.0)
: Define a radial gradient that starts in the left edge of the view centered vertically with an initial radius of 200, and reduce to a radius of 50 to the right-most edge centered vertically.Note
When using different centers for a radial gradient, the resulting gradient might be unexpected.
Declaration
Swift
case radial(startCenter: CGPoint, startRadius: CGFloat, endCenter: CGPoint, endRadius: CGFloat)