Created
November 26, 2021 21:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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