代码语言:javascript复制
//星期 月日 时分 上下午
UIDatePicker dk = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 20, 320, 200)];
[self.view addSubview:dk];
//四种 类型
dk.datePickerMode = UIDatePickerModeCountDownTimer;
/
UIDatePickerModeTime, // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
UIDatePickerModeDate, // Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
UIDatePickerModeDateAndTime, // Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
UIDatePickerModeCountDownTimer, // Displays hour and minute (e.g. 1 | 53)
*/
dk.minuteInterval = 5;//被60整除的数 显示时间间隔
dk.minimumDate = //NSDate 最小时间
//NSDate* minDate = [[NSDate alloc]initWithString:@"1900-01-01 00:00:00 -0500"];
dk.maximumDate = //NSDate 最大时间
dk.date = //设置默认显示日期
//添加事件
[dk addTarget:self action:@selector(clickDatePicker:) forControlEvents:UIControlEventValueChanged];</pre>