设置UIDatePicker的允许最大时间、最小时间:
self.frame= CGRectMake(0,0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);
datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0,44, CGRectGetWidth(self.frame),216)];
datePicker.datePickerMode= UIDatePickerModeDate;
datePicker.locale= [NSLocalelocaleWithLocaleIdentifier:@"zh"];
datePicker.backgroundColor= [UIColorwhiteColor];
NSCalendar*calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDate*currentDate = [NSDatedate];
NSDateComponents*comps = [[NSDateComponents alloc]init];
[compssetYear:10];//设置最大时间为:当前时间推后十年
NSDate*maxDate = [calendardateByAddingComponents:compstoDate:currentDateoptions:0];
[compssetYear:-10];//设置最小时间为:当前时间前推十年
NSDate*minDate = [calendardateByAddingComponents:compstoDate:currentDateoptions:0];
[datePicker setMaximumDate:maxDate];
[datePicker setMinimumDate:minDate];