Making the color sliders
To start creating the sliders, make a new SwiftUI View file and call it SliderView
.
As the sliders are only used to manipulate the guess circle, we won’t need any Target
variables in this file. Instead, we just need three Guess
variables, as well as a variable to track the value of the picker control, which you can add like this:
@Binding var redGuess: Double @Binding var greenGuess: Double @Binding var blueGuess: Double @Binding var selectedPickerIndex: Int
Again, we need to update the Previews
struct, because it’s giving us this error: Missing arguments for parameters redGuess, greenGuess, blueGuess, selectedPickerIndex in call. This error is telling us, as it has before, to include the Binding
variables in its SliderView
struct initializer. Let’s give it what it wants, by updating Previews
with the following code:
struct StyleTheSliders_Previews...