This framework relies on (and installs):
Add the following to your Cartfile
github "kautenja/UIPopupDatePicker" ~> 1.1
To run the example project, clone the repo, and build it on devices of you choosing.
The main entry point for UIPopupDatePicker is the static show
method.
_ = UIPopupDatePicker.show(on: self, with: nil, block: nil)
This function returns an instance of UIPopupDatePicker in case you might want to manipulate some of the controller manually:
let popup = UIPopupDatePicker.show(on: self, with: nil, block: nil)
popup.headerText = "Some text you might want as a title!"
To respond to a change in the date use the callback handler:
_ = UIPopupDatePicker.show(on: self, with: Date()) { (selected) in
NSLog("UIPopupDatePicker returned \(selected) in the callback")
}
the parameter passed to the anonymous function an optional date (Date?
). If the user:
- presses done
the callback will be executed with the date from the calendar and time from the picker. If the time picker is hidden, the time will be the time that the popup was first created.
- presses clear
the callback will be executed passing nil
as the parameter to the anonymous function.
Use this to remove a date from something.
- presses cancel
the callback IS NOT executed and the popup dismisses with no changes to the parent view controller.
see ViewController for a production example of how this might come together
Kautenja, kautencreations@gmail.com
TL;DR do what you want with it.
UIPopupDatePicker is available under the MIT license. See the LICENSE file for more info.