See this simple example. Putting DatePicker
in VStack
has weird layout issue and causes all the content in VStack
to not show up (I'm using XCode 13.2 + iOS15.2).
struct ContentView: View {
@State var date: Date = Date()
var body: some View {
Form {
VStack {
DatePicker("Date", selection: $date)
Text("date: \(date)")
}
}
}
}
Replacing the DatePicker
with other views (e.g. TextField
) works fine. Removing the VStack
also works fine. However, I need to have the VStack
to make subviews inside it to show up in a single cell.
I googled but wasn't able to find any discussion about this issue. I tried to wrap DatePicker
in HStack
or ZStack
but neither worked. Does anyone know how to work around this issue? Thanks.