How to customise the UIDatePicker components in swift?

2.7k Views Asked by At

For custom date picker I am using the

https://github.com/squimer/DatePickerDialog-iOS-Swift

its working fine but I need to add two things on this

1.I need to re arrange the components order like date/month/year(i.e 23/05/2016) instead of the month/date/year(i.e 05/23/2016).

2.I need another datepicker object with only two components i.e month/year (may/2016).

How can I achieve this

Thank you in advance

1

There are 1 best solutions below

3
On

You cannot do this with UIDatePicker, and since that project uses UIDatePicker, you can't do it with that project.

UIDatePicker has extremely limited customization options. You can have it show a date, or a time, or both. But you can't tell it how to display the date, so you can't rearrange the components or choose which date components to show.

If you need these formats, you will need use UIPickerView and implement your own delegate and dataSource methods to display the options that you need. Or maybe you can find a different open source project that does what you need.