The final view to be added to the stack before we start to tidy up the layout is a Picker view. The purpose of this view will be to allow the foreground color of the Text view to be chosen by the user from a range of color options. Begin by adding some arrays of color names and Color objects, together with a state property to hold the current array index value as follows:
import SwiftUI
struct ContentView: View {
var colors: [Color] = [.black, .red, .green, .blue]
var colornames = ["Black", "Red", "Green", "Blue"]
@State private var colorIndex = 0
@State private var rotation: Double = 0
@State private var text: String = "Welcome to SwiftUI"
With these variables configured, display the Library panel, locate the Picker in...