方式一:確定和取消按鈕在時間選擇器的底部
letalertcontroller:
uialertcontroller
=uialertcontroller
(title:
"\n\n\n\n\n\n\n\n\n"
, message:
nil, preferredstyle:
uialertcontrollerstyle
.actionsheet)
// 初始化
datepicker
letdatepicker =
uidatepicker
( )
//將日期選擇器區域設定為中文,則選擇器日期顯示為中文
datepicker.
locale
=nslocale
(localeidentifier:
"zh_cn"
) as
locale
// 設定樣式,當前設為同時顯示日期和時間
datepicker.
datepickermode
=uidatepickermode
.date
// 設定預設時間
datepicker.
date
=nsdate
()as
date
// 響應事件(只要滾輪變化就會觸發)
// datepicker.addtarget(self, action:selector("datepickervaluechange:"), forcontrolevents: uicontrolevents.valuechanged)
alertcontroller.
addaction
(uialertaction
(title:"確定
", style:
uialertactionstyle
.default))
alertcontroller.
addaction
(uialertaction
(title:"取消
", style:
uialertactionstyle
.cancel
,handler:
nil))
alertcontroller.
view
.addsubview
(datepicker)
self
.present
(alertcontroller, animated:
true
, completion:
nil)
方式二:使用actionsheetpicker-3.0
letpicker=
actionsheetdatepicker
(title:
"", datepickermode:
uidatepickermode
.date
, selecteddate:
nsdate
()as
date
!, doneblock: , cancel: , origin:
self
.viewstarttime)
picker?.
setdonebutton
(uibarbuttonitem
(title:"確認
", style:
uibarbuttonitemstyle
.plain
, target:
self
, action:
nil))
picker?.
setcancelbutton
(uibarbuttonitem
(title:"取消
時間選擇器
nsstring start 2016 2 2 08 00 nsstring end 2016 2 2 20 00 nstimeinterval interval 30 nsmutablearray arr cuttingdatetool nslog arr pickervc timepickerv...
時間選擇器
wxml 時間選擇器 選擇時分 日期選擇器 選擇年月日 國慶出遊 日期時間選擇器 精確到秒 日期時間選擇器 精確到分 jsvar datetimepicker require utils datetimepicker.js page onload changedate e changetime e ...
MUI datepicker(時間選擇器)
完整 選擇日期 選擇時間 document.getelementbyid pickdatebtn addeventlistener tap function function e document.getelementbyid picktimebtn addeventlistener tap fun...