标签:
时间选择器 UIDatePicker 继承自 UIControl
初始化时间选择器的方式:
picker =[[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
时间选择器的格式:
picker.datePickerMode = UIDatePickerModeDate;(只显示年月日)UIDatePickerModeTime (显示上午或下午和时 分)UIDatePickerModeDateAndTime(显示月份日期,周几,上午或下午和时 分)
UIDatePickerModeCountDownTimer(。。。。。。)
// 设置最小的时间范围
picker.minimumDate =[NSDate dateWithTimeIntervalSince1970:0];
// 设置最大的时间范围
picker.maximumDate =[NSDate dateWithTimeIntervalSinceNow:24*60*60*365*10];
[picker addTarget:self action:@selector(didFinishSelectDate:) forControlEvents:UIControlEventValueChanged];
-(void)didFinishSelectDate:(UIDatePicker *)sender{
NSLog(@"%@",sender.date);
}
标签:
原文地址:http://www.cnblogs.com/popper123/p/4821945.html