Hi I have a UIDatePicker
with inline
style and dateAndTime
mode as InputView to a UITextField, and when datePicker appears its not showing the days and the time. Please refer the image1(when it appears) and image2(when tap on time).
This is my code
func createDatePicker(startDate: Date) {
let toolbar = UIToolbar()
toolbar.sizeToFit()
let doneBtn = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(donePressed))
let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let cancelBtn = UIBarButtonItem(barButtonSystemItem: .cancel, target: nil, action: #selector(cancelPressed))
toolbar.setItems([cancelBtn, space, doneBtn], animated: true)
datePicker.locale = .current
datePicker.datePickerMode = .dateAndTime
datePicker.minimumDate = startDate
if #available(iOS 14, *) {
datePicker.preferredDatePickerStyle = .inline
datePicker.sizeToFit()
} else {
}
self.starDateTimeTF.inputAccessoryView = toolbar
self.starDateTimeTF.inputView = datePicker
}
And how I'm expecting is like this,
Please help.