UIDatePicker在方法上的之前的没有区别,显著的区别就是在显示上。IOS 7的效果还是不错的,主要是没有边框显示。两者结合下就好了。
代码:
UIDatePicker * datePicker=[[UIDatePickeralloc] initWithFrame:CGRectMake(0,40, 320,320)];
NSDateFormatter *dateFormat = [[NSDateFormatteralloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSDate *todayDate = [NSDatedate];
[datePicker setDate:datePicker.date];
[datePicker setMaximumDate:todayDate];
[dateFormat release];
datePicker.datePickerMode=UIDatePickerModeDate;
[self.viewaddSubview:datePicker];
//[datePicker addTarget:self action:@selector(pickDidChange:) forControlEvents:UIControlEventValueChanged];
[datePicker release];
如图: