HomeiOS Developmentios - Utilizing SwiftUI how can I power a DatePicker to make...

ios – Utilizing SwiftUI how can I power a DatePicker to make use of the 24 Hour date format slightly than the locale the person has on their system


I’m attempting to power my SwiftUI DatePicker to override the person’s settings and solely show a 24 hour time format. This is able to be related in an aviation associated app. I’ve seen some outdated posts utilizing UIDatePicker and overriding the locale, nonetheless that does not work for the precise system utilizing the next:

DatePicker("Begin Time", choice: $startTime, displayedComponents: DatePickerComponents.hourAndMinute)
    .atmosphere(.locale, Locale.init(identifier: "en_GB"))

After I run this on my system with area set to US, it nonetheless shows hours and minutes with am/pm. I’ve tried different locales resembling en_DK however nonetheless shows am/pm.

I can implement a customized popover and wheel spinners to imitate this, however that runs into points on an iPhone going fullScreen. I am certain there are different work arounds utilizing customized logic, however I used to be questioning if there may be anyway to power the native DatePicker to make use of am/pm.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments