Creating PickerView
A PickerView
is a view that displays various options to the user. The picker can either be a single button with a drop-down list, a segmented list with multiple buttons, or a wheel that the user can spin to select an option.
There are two main differences between these three pickers in terms of style. The first is how they appear in your app. The second is the number of options available to the user – the wheel can hold many, many options for the user, whereas a button picker or a segmented control picker is limited by the amount of space on the screen.
Since we will be offering just three options to the user, a seven-, eight-, or nine-letter word option, we’ll go with the segmented control.
Adding PickerView
Let’s start by adding a new SwiftUI View file and calling it PickerView
. Next, let’s add an instance of the DataModel
class at the top of the struct so we have access to the data properties:
@ObservedObject var appData...