I want to show a DatePicker in SwiftUI. But the SwiftUI have no interface to customization the style of DatePicker, etc, font size ,font color . So I want to use a button to show DatePicker. After click this button , the SwiftUI DatePicker will be present.
Is there any way to implement this?
struct ContentView: View {
@State private var date = Date()
var body: some View {
VStack {
ZStack() {
DatePicker(selection: $date, in: ...Date(), displayedComponents: .date) {
Text("")
}
.opacity(0.01)
HStack() {
Text("Start Time")
Spacer()
Button("2021-08-22") {
print("Button was tapped")
// present DatePicker...
}
}
}
.frame(height: 44)
.padding(.horizontal, 20)
}
}
}