titanium mobile date picker from text field

2019-06-06 20:25发布

问题:

I want to do the following: when people click on a text field they see a date picker. they click "done" button at the top and the date picker disappears and they are back on the form. How can I accomplish this using titanium mobile for iphone ios?

回答1:

You can use Textbox AddeventListener and Animation function. like

var donebtn = Ti.UI.createButton({
title : "Done",

});

var toolbar_pick    = Ti.UI.iOS.createToolbar({
      backgroundColor : "#f00",
      bottom        : -50,
      items       :[donebtn],
      barColor      :'#000',

});

var _date = Ti.UI.createPicker({
    type:Ti.UI.PICKER_TYPE_DATE,
    minDate : new Date,
    bottom :-320 ,
});
donebtn.addEventListener('focus',function(){
     _date.animate({bottom:-270, duration: 500});
     toolbar_pick.animate({bottom:-50, duration: 500});

});
textbox.addEventListener('click',function(){
    _date.animate({bottom:0, duration: 500});
    toolbar_pick.animate({bottom:266, duration: 500});


});
win.add(_date);
win.add(toolbar_pick);

just for example can use own your requirement.

MRT