How To Hide Label In Date Picker In SwiftUI

Date Picker is a useful thing because it saves us a lot of time because we don’t have to create our own pickers. However, it has always presented text related to it but there is an option to hide that label.

When you create Wheel Date Picker you need to put some text into the constructor.

@State private var date = Date()

DatePicker(“Date Picker Text”, selection: $date)
    .
datePickerStyle(WheelDatePickerStyle())

Even if you remove it and put empty text then there will be some space for that text.

To remove that text or empty space there is .labelsHidden view modifier.

DatePicker(“Date Picker Text”, selection: $date)
    .
datePickerStyle(WheelDatePickerStyle())
    .
labelsHidden()

Now, there is only a picker on the screen.