does anyone know how to give the minutes DatePicker an interval? I am trying to only display multiples of 15 (0, 15, 30, 45). Is this only yet possible by interfacing with UIKit?
I believe it's not using the in: ...Date()
part, at least I couldn't think of a solution. Here is my snippet:
DatePicker(
"",
selection: $selectedDate,
/*in: ...Date(),*/
displayedComponents: .hourAndMinute
)
Thanks so much!
The solution is to configure using UIDatePicker.appearance
before SwiftUI DatePicker
is created.
Tested with Xcode 13.3 / iOS 15.4
Main part is:
UIDatePicker.appearance().minuteInterval = 15
Complete code in here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With