Last updated 1 year ago
struct DatePicker<Label> where Label :
SwiftUI Tutorials โฉ Working with UI Controls โฉ Sec 3.
โฉ
View
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() }