How to make a UIDatePicker appear at bottom of scr

2019-04-09 16:50发布

问题:

I currently use MonoTouch with MonoTouch.Dialog. When tapping on a date field it pushes the navigationcontroller so you go right a screen to see your UIDatePicker where you choose the date then go "back" to the main screen again. I'd really like to have this UI like other apps I've used that when you select a date field the UIDatePicker appears at the bottom of the current screen.

I would like to learn how to do this and apply it to other input fields where I may want to use a custom picker that also presents itself at the bottom of the current screen.

Does anyone have any code to share that would allow a UIPicker/UIDatePicker to appear at the bottom of the active screen?

Thank you.

回答1:

You just create a UIPickerView normally, but set its frame outside of the visible area. Once you click on a cell, you change the origin point of the UIPickerView's frame, so that the picker view will become visible. You can animate the property frame, so you can make a nice soft animation that your picker view will slide in from the lower boundary of the phone.