WeCan
WeCan

Reputation: 597

How to hide some of the years in UIDatePicker in Swift?

I need to restrict the years in UIDatePicker, i.e set year is hidden if the year is more than our maximum date.

For this I already tried like myDatePicker.maximumDate=NSDate()

My date picker like UIDatePickerView

Now how can I remove or hide the year values more than(i.e 2016) our maximum date.

Thankyou

Upvotes: 1

Views: 2033

Answers (2)

William GP
William GP

Reputation: 1332

If that is really what you want - I think you have to build a custom picker yourself using UIPickerView.

Per iOS docs, "The appearance of UIDatePicker is not customizable."

Upvotes: 1

you need to set validation on picker. so set the maximum date and minimum date of picker. ////

 self.datePicker.minimumDate = minDate;
    self.datePicker.maximumDate = maxDate;

Upvotes: 0

Related Questions