ios - How to show date range by using UIDatePicker in Swift -
i have uidatepicker sheet used in project. naturally shows 1 day per date. wanna see day , 9 days after day. how can it?
for example,
____________ july 13 2015 (today) july 14 2015 july 15 2015 ____________ july 16 2015 july 17 2015 july 18 2015 july 19 2015 july 20 2015 july 21 2015
only 9 days today.
uidatepicker
has 2 properties - minimumdate, maximumdate: nsdate?
they nil default, can set them this:
let currentdate: nsdate = nsdate() let calendar: nscalendar = nscalendar.currentcalendar() let components: nsdatecomponents = nsdatecomponents() components.calendar = calendar components.day = 9 let maxdate: nsdate = calendar.datebyaddingcomponents(components, todate: currentdate, options: nil)! self.mydatepicker.minimumdate = currentdate self.mydatepicker.maximumdate = maxdate
Comments
Post a Comment