
SwiftUI Cookbook
By :

SwiftUI has several ways of rendering gradients. A gradient can be used to fill a shape, or even fill a border, as you will see in the Rendering a border with a gradient recipe later in this chapter.
In this recipe, we will be focused on understanding what types of gradients we can use with SwiftUI and how to define them.
Create a SwiftUI app called GradientViewsApp
.
SwiftUI has three different types of gradients:
In each one, we can define the list of the colors that will smoothly transform into each other and, depending on the type of gradient, we can also define some additional properties such as the direction, radius, and angles of the transformation.
To explore all of them, we are going to add a a Picker component
to select the type of gradient.
The ContentView
struct will have a Text
component that shows the selected...