说我有一个简单的DatePicker,例如:
DatePicker(
selection: $date,
in: dateClosedRange,
displayedComponents: .date,
label: { Text("") }
)
我的日期范围定义为:
var dateClosedRange: ClosedRange<Date> {
let min = Calendar.current.date(byAdding: .year, value: -120, to: Date())!
let max = Calendar.current.date(byAdding: .day, value: 1, to: Date())!
return min...max
}
当前,当用户选择的日期超出范围时,DatePicker会恢复为开始日期(今天)。我该如何创建一个平滑的动画,而不是回到起始日期?