iosswiftswiftui

How to change the size of DatePicker in SwiftUI


Does anybody know how to change the size of the default DatePicker in SwiftUI? I have been trying to provide a custom frame to resize the DatePicker but I could't see the expected outcome.

Thanks in advance!

Here is what I tried

DatePicker("", selection: $currentDate, displayedComponents: .hourAndMinute)
                              .labelsHidden()
                              .frame(width: 150, height: 80, alignment: .center)

Solution

  • Just clip it at the end as below...

    DatePicker("", selection: $currentDate, displayedComponents: .hourAndMinute)
        .labelsHidden()
        .frame(width: 150, height: 80, alignment: .center)
        .clipped()