Https://github.com/potato512/SYSwiftLearning
Effect chart
Sample code
Instantiate Uidatepicker (default width is: screen width, height of 216) let
DatePicker = Uidatepicker ()
Self.view.addSubview (DatePicker)
//property settings
Datepicker.backgroundcolor = Uicolor.lightgraycolor ()
//Date Display Properties
Datepicker.datepickermode = Uidatepickermode.dateandtime
//Set default time
Datepicker.setdate (NSDate (), animated:true)
//min, max time selection settings
datepicker.minimumdate = NSDate (timeinterval: -93312000, Sincedate:nsdate ())
datepicker.maximumdate = NSDate (timeintervalsincenow:93312000)
//Time minute interval set
Datepicker.minuteinterval = 5
// Set Date selector area to Chinese (default display english)
Datepicker.locale = Nslocale (localeidentifier: "ZH_CN")
//Add Method
Datepicker.addtarget (Self, Action:selector ("datechanged:"), forControlEvents:UIControlEvents.ValueChanged)
Display Select time let
label = Uilabel (Frame:cgrectmake (10.0, Cgrectgetheight (self.view.bounds)-10.0-40.0), (Cgrectgetwi DTH (Self.view.bounds)-10.0 * 2), 40.0)
self.view.addSubview (label)
Label.autoresizingmask = Uiviewautoresizing.flexibletopmargin
Label.backgroundcolor = Uicolor.yellowcolor ()
Label.textColor = Uicolor.redcolor ()
Label.tag = 1000
MARK:-Date Selector response method
func datechanged (datepicker:uidatepicker)
{
//Update reminder time text box let
formatter = NSDateFormatter ()
Formatter.dateformat = "yyyy year mm month DD Day HH:MM:SS" let
date = Datepicker.date
let Datetext = formatter.stringfromdate (date) let
label = SELF.VIEW.VIEWWITHTAG (1000) as! Uilabel
label.text = Datetext
}