title: Swift 3 Displaying a programmatically created datePicker using a UINavBar Button
body: <p>I've created a <code>UIPickerView</code> programmatically that I currently call from a <code>UITextField</code>. Instead I would like to call the <code>datePicker</code> when the user presses a button created programmatically on the navigation bar. This is what my <code>datePicker</code> code currently looks like:</p>
  
  <pre><code>func doDatePicker(){
      // DatePicker
      self.datePicker = UIDatePicker(frame:CGRect(x: 0, y: 0, width:     self.view.frame.size.width, height: 216))
      self.datePicker?.backgroundColor = UIColor.white
      self.datePicker?.datePickerMode = UIDatePickerMode.dateAndTime
      HVACText.inputView = self.datePicker
  
      // ToolBar
      let toolBar = UIToolbar()
      toolBar.barStyle = .default
      toolBar.isTranslucent = true
      toolBar.tintColor = UIColor(red: 92/255, green: 216/255, blue:  255/255, alpha: 1)
      toolBar.sizeToFit()
  
      // Adding Button ToolBar
      let doneButton = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(HVACViewController.doneClick))
      let spaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
      let cancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(HVACViewController.cancelClick))
      toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
      toolBar.isUserInteractionEnabled = true
      HVACText.inputAccessoryView = toolBar
  
  }
  </code></pre>
  
  <p>I can use the button to call a generic datePicker, but I want to have the Done and Cancel button available to the user. I also want the datePicker to appear at the bottom of the UITableView. I do not want to segue away from the view.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Here's the screen shot as requested. Please note that the interface is a work in progress, the textfield will be going away.</p>
  
  <p><a href="https://i.stack.imgur.com/u56EL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u56EL.png" alt="Screen Shot"></a></p>