Source code :
//
// ContentView.swift
// Picker
//
// Created by Saveta Mobile Academy on 01.03.21.
//
import SwiftUI
struct ContentView: View {
@State private var selectedType = 0
private var priorities = ["Low", "Medium", "High"]
var body: some View {
NavigationView{
VStack {
Form {
Section(header: Text("Choose priority:")) {
Picker(selection: $selectedType, label:Text("")) {
ForEach(0 ..< self.priorities.count) {
Text(self.priorities[$0])
}
}
.pickerStyle(SegmentedPickerStyle()).padding(2)
}.textCase(nil)
Section(header: Text("Choose priority:")) {
Picker(selection: $selectedType, label:Text("Priority")) {
ForEach(0 ..< self.priorities.count) {
Text(self.priorities[$0])
}
}
.pickerStyle(DefaultPickerStyle()).padding(2)
}.textCase(nil)
Section(header: Text("Choose priority:")) {
Picker(selection: $selectedType, label:Text("Priority")) {
ForEach(0 ..< self.priorities.count) {
Text(self.priorities[$0])
}
}
.pickerStyle(InlinePickerStyle()).padding(2)
}.textCase(nil)
Section(header: Text("Choose priority:")) {
Picker(selection: $selectedType, label:Text("Priority")) {
ForEach(0 ..< self.priorities.count) {
Text(self.priorities[$0])
}
}
.pickerStyle(MenuPickerStyle()).padding(2)
}.textCase(nil)
}
}.edgesIgnoringSafeArea(.top).navigationBarTitle("Priority",displayMode: .inline)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}