What I'm trying to approach is when user clicks on a button, a datepicker will show up at the bottom of screen. This is what I currently have but datepicker is taking the entire screen and shown as a popover.
VStack {
Text("Birthdate").padding()
Button(action: {
self.showSheet = true
}) {
Text(startDate.toMediumString())
}
.sheet(isPresented: $showSheet){
DatePicker("", selection: self.$startDate, in: ...Date(), displayedComponents: .date)
.labelsHidden()
}
}
or this is even better if there's already a built in component I can use.
Sorry no chance to check. But i did something this
VStack {
Text("Birthdate").padding()
Button(action: {
self.showSheet = true
}) {
Text(startDate.toMediumString())
}
...
Spacer(minLength: 120)
if (self.showSheet == true){
HStack(alignment: .bottom) {
DatePicker("", selection: self.$startDate, in: ...Date(), displayedComponents: .date)
.labelsHidden()
}
.padding(EdgeInsets.init(top: 30, leading: 40, bottom: 120, trailing: 50)).background(Color.gray.opacity(0.1))
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.