'is there is a way to show old date and time picker in swift
I am new in swift and I am facing problem with new date picker I need to show old date piker

But the current date piker is like this

Is there is any way to show old picker
My code is like this
func showDatePickerFrom(){
//Formate Date
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
let result = formatter.string(from: date)
let dateToday = formatter.date(from: result)
FromdatePicker.datePickerMode = .date
FromdatePicker.maximumDate = dateToday
//ToolBar
let toolbar = UIToolbar();
toolbar.sizeToFit()
let doneButton = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(donedatePicker))
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(cancelDatePicker))
toolbar.setItems([cancelButton,spaceButton,doneButton], animated: false)
txtdateselect.inputAccessoryView = toolbar
txtdateselect.inputView = FromdatePicker
}
@objc func donedatePicker(){
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy"
txtdateselect.text = formatter.string(from: FromdatePicker.date)
self.view.endEditing(true)
}
@objc func cancelDatePicker(){
self.view.endEditing(true)
}
Solution 1:[1]
From iOS 13.4, Apple change the way it show picker.
To show date picker in old way, just add below lines in the code.
if #available(iOS 13.4, *) {
self.preferredDatePickerStyle = .wheels
}
Note : You have to write this line right after you initialize date picker.
E.x. If you write this line after setting maximum or minimum date, it won't work like below.
if #available(iOS 13.4, *) {
self.preferredDatePickerStyle = .wheels
}
self.minimumDate = Date()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fahim Parkar |
