SwiftUI Tutorials โฉ Working with UI Controls โฉ Sec 3.
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()
}