Picker is a control in SwiftUI which allows you to select a value from a list of possible options. There are many types of inbuilt pickers coming in SwiftUI and it’s really easy to implement.
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/02/PickerInSwiftUI.jpg?resize=825%2C464&ssl=1)
Automatic Style Picker (In Form)
Automatic style of picker in form will come with navigation link setup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import SwiftUI struct ContentView: View { var options = ["One", "Two", "Three"] @State private var selectedOption = "One" var body: some View { NavigationView { Form { Picker("Select", selection: $selectedOption) { ForEach(options, id: \.self) { Text($0) } }.pickerStyle(.automatic) } .navigationTitle("Testing the form!") } } } |
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/03/1_Default-1.png?resize=207%2C207&ssl=1)
Inline Style Picker
.pickerStyle(.inline) this will look as follows:
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/03/2_Inline-1.png?resize=207%2C207&ssl=1)
Menu Style Picker
.pickerStyle(.menu) this will look as follows:
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/03/3_Menu-2.png?resize=207%2C207&ssl=1)
Segmented Style Picker
.pickerStyle(.segmented) this will look as follows:
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/03/4_Segmented-1.png?resize=207%2C207&ssl=1)
Wheel Style Picker
.pickerStyle(.wheel) this will look as follows:
![](https://i0.wp.com/ashishkakkad.com/wp-content/uploads/2022/03/5_Wheel-1.png?resize=207%2C207&ssl=1)
Conclusion
Let me know if you have any questions, comments, or feedback – either via Twitter or email.
Happy Coding 🙂