我现在在里面添加了 datePicker HStack
。我只想datePicker
在textField
处于编辑模式时显示。
struct EditProfile: View {
@Binding var profile: Profile
var body: some View {
List {
HStack {
Text("Username").bold()
TextField("Date")
DatePicker(
$profile.goalDate,
minimumDate: Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate),
maximumDate: Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate),
displayedComponents: .date
)
}
}
.padding(.top)
}
.padding(.top)
}