ios - How to only display the time in UIDatePicker? -
this question has answer here:
i need change code display time in uidatepicker.
func textfielddidbeginediting(textfield: uitextfield) { if textfield == textfielddataselection { let datepicker = uidatepicker () textfield.inputview = datepicker datepicker.addtarget(self, action: "datepickerchanged:", forcontrolevents: .valuechanged) } if textfield == textfielddeadline { let datepicker = uidatepicker () textfield.inputview = datepicker datepicker.addtarget(self, action: "date1pickerchanged:", forcontrolevents: .valuechanged) } } func datepickerchanged(sender:uidatepicker) { let formatter = nsdateformatter() formatter.datestyle = .mediumstyle textfielddataselection.text = formatter.stringfromdate(sender.date) } func date1pickerchanged(sender:uidatepicker) { let formatter = nsdateformatter() formatter.dateformat = "mmm dd, yyyy hh:mm a" textfielddeadline.text = formatter.stringfromdate(sender.date)
set
datepicker.datepickermode = uidatepickermode.time
Comments
Post a Comment