SwiftUI DatePicker - graphical datepicker style rendering problem

Hi! I was exploring the DatePicker functionality in SwiftUI from official documentation: https://developer.apple.com/documentation/swiftui/datepicker

When I tried using graphical datepicker style, I got the warning message generated for the next code ( copied from documentation example)



var body: some View {
    DatePicker(
        "Start Date",
        selection: $date,
        displayedComponents: [.date]
    )
    .datePickerStyle(.graphical)
}

I got the next warning message:

[UICalendarView] UICalendarView's height is smaller than it can render its content in; defaulting to the minimum height.

Could I please ask you how to fix that ? I tried setting the frame to .frame(width: 320) but that is not what I want to achieve. Would be grateful for any advice!

Thank you!

I tried setting the frame to .frame(width: 320)

That's a warning you can ignore. However, it is about height.

So change to

var body: some View {
    DatePicker(
        "Start Date",
        selection: $date,
        displayedComponents: [.date]
    )
    .datePickerStyle(.graphical)
    .frame(width: 320, height: 320)}

I tested, it silences the warning (need to specify both width and height)

SwiftUI DatePicker - graphical datepicker style rendering problem
 
 
Q