๐ŸŽ›๏ธDatePicker

struct DatePicker<Label> where Label : View

๐Ÿ‘‰ SwiftUI Tutorials โŸฉ Working with UI Controls โŸฉ Sec 3. Define the Profile Editor

var dateRange: ClosedRange<Date> {
    let min = Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate)!
    let max = Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate)!
    return min...max
}

DatePicker(
    selection: $profile.goalDate,
    in: dateRange,
    displayedComponents: .date
) {
    Text("Goal Date").bold()
}

Last updated