I have set inline style date for iOS 14. In this date picker timer picker is display at bottom. I want to display that time picker at top of inline style date picker like display in iOS default calendar app.
My app screen shot:
iOS default calendar app screen shot:
Display the current date in a date pickerClick the Data tab. Under Default Value, click Insert Formula . In the Insert Formula dialog box, click Insert Function. In the Categories list in the Insert Function dialog box, click Date and Time.
A date picker, popup calendar, date and time picker, or time picker is a graphical user interface widget which allows the user to select a date from a calendar and/or time from a time range.
In android DatePicker having two modes, the first one shows the complete calendar and the second one shows the dates in the spinner view. One can create a DatePicker control in two ways either manually in the XML file or create it in the Activity file programmatically.
UIKit
does not officially support Time Picker above the Date Picker inside an in-line UIDatePicker
.
However, you can just create 2 Date Pickers, one for the date and one for the time, and then arrange them however you want.
This code that I made might help you:
let time = timePicker.date
var date = datePicker.date
date = Calendar.current.startOfDay(for: date)
let calendar = Calendar.current
var timeInterval: TimeInterval = 0
timeInterval += Double(calendar.component(.second, from: time))
timeInterval += Double(calendar.component(.minute, from: time)) * 60
timeInterval += Double(calendar.component(.hour, from: time)) * 3600
date.addTimeInterval(timeInterval)
Then use the variable date
, and everything should work like in a regular date-and-time Date Picker.
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