Why UIDatePicker is not showing the time and days in .inline style in iOS 15

545 Views Asked by At

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).

When datePicker appears

When tap on the 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, enter image description here

Please help.

0

There are 0 best solutions below