How can I make the DatePicker stay opened in form?
I put the DatePicker inside of Form, so I have to tap form, to open the DatePicker. But instead, I want it to be always open, even when the user didn't tap then form. Would be there anyway to achieve this?
Here is my current code.
struct ContentView: View {
@State private var selectedDate = Date()
var body: some View {
VStack{
Form{
DatePicker(selection: self.$selectedDate, in: Date()..., displayedComponents: .date, label: { Text("Select a date") })
}
}
}
}
And here is what I have tried. Using this method
struct ContentView: View {
@State private var pickerReset = UUID()
@State private var selectedDate = Date()
var body: some View {
VStack{
Form{
DatePicker(selection: self.$selectedDate, in: Date()..., displayedComponents: .date, label: { Text("Select a date") }).id(self.pickerReset)
}
}.onAppear{
//I tired to show datePicker with UUID(), but
//this line of code ratherly hide the datepicker
self.pickerReset = UUID()
}
}
}