I want to add a Done button within a popped up datePickerView in Swift.
Here is the code:
@IBOutlet var datePicker: UITextField!
@IBAction func date
In Swift 5
If you want only Done button on DatePicker use my code
//Write toolbar code for done button
let toolBar = UIToolbar()
toolBar.barStyle = .default
toolBar.isTranslucent = true
let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(onClickDoneButton))
toolBar.setItems([space, doneButton], animated: false)
toolBar.isUserInteractionEnabled = true
toolBar.sizeToFit()
dobTF.inputAccessoryView = toolBar //Change your TextField name here
@objc func onClickDoneButton() {
self.view.endEditing(true)
}