Sunday, July 28, 2024
HomeiOS Developmentios - SwiftUI DatePicker time from now till tomorrow identical time

ios – SwiftUI DatePicker time from now till tomorrow identical time


I am trying so as to add a easy DatePicker time selector in my SwiftUI app. The thought is to pick out the time of your subsequent appointment and calculate when you’ll want to depart.

Within the DatePicker you may choose the date ranges through the use of the in: startDate...endDate performance so it could make sense to set the date vary to be:

    let startDate = Date()
    let endDate = Date(timeIntervalSinceNow: 24 * 3600.0)

however from what I can see, the time picker solely permits me to pick out the time from now till midnight tomorrow. What am I doing fallacious right here?

Simulator with code showing disabled time before current time

DatePicker("What time do you need to arrive at?", choice: $appointmentTimes.arrivalTime,
                           in: startDate...endDate,
                           displayedComponents: .hourAndMinute)
                    .labelsHidden()
                    .font(.largeTitle)
                    .datePickerStyle(.wheel)
                    .onAppear {
                        UIDatePicker.look().minuteInterval = 5
                    }

Replace:
Eradicating the show elements provides me a capability to indicate the date which might then work considerably appropriately, permitting me to pick out tomorrow occasions till now. However since I wish to preserve it easy, I’d reasonably have simply have it present the occasions.

enter image description here



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments