IT虾米网

UIDatePicker 日期时间选择器

wyy 2018年06月24日 手机开发 1271 0
//星期 月日 时分 上下午 
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];

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!