Skip to content

Instantly share code, notes, and snippets.

@zentrope
Created November 26, 2021 21:40
Show Gist options
  • Save zentrope/5afe4ece1cf245bd03e7098f0967ac9f to your computer and use it in GitHub Desktop.
Save zentrope/5afe4ece1cf245bd03e7098f0967ac9f to your computer and use it in GitHub Desktop.
Picker (like Mac's Contacts App) -- But there's no way to hide the background button style in SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
ContactEditor()
.frame(width: 500)
}
}
struct ContactEditor: View {
private let fields = ["mobile", "home", "work", "bill-collectors"];
@State private var phone = "";
@State private var field = "mobile"
var body: some View {
VStack {
HStack {
Picker("", selection: $field) {
ForEach(fields, id: \.self) { field in
Text(field).tag(field)
}
}
.fixedSize()
.pickerStyle(.menu)
TextField("Phone number", text: $phone)
}
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment