标签:mini return picker 整数 make get enter cti when
// 不设置 frame 时为系统默认大小
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
// 将 datePicker 添加到屏幕上
[self.view addSubview:datePicker];
// 设置 frame
/*
不设置 frame 时为系统默认大小
*/
datePicker.frame = CGRectMake(50, 100, self.view.bounds.size.width - 100, 300);
// 设置位置
datePicker.center = self.view.center;
// 设置显示模式
/*
UIDatePickerModeTime, // 仅显示时间,不显示日期
UIDatePickerModeDate, // 仅显示日期,不显示时间
UIDatePickerModeDateAndTime, // 同时显示日期和时间,默认
UIDatePickerModeCountDownTimer, // 显示为倒计时状态
*/
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
// 设置本地化信息
/*
default is [NSLocale currentLocale]. setting nil returns to default
*/
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
// 设置时区
/*
default is nil. use current time zone or time zone from calendar
*/
datePicker.timeZone = [NSTimeZone systemTimeZone];
// 设置日历
/*
default is [NSCalendar currentCalendar]. setting nil returns to default
*/
datePicker.calendar = [NSCalendar currentCalendar];
// 设置时间
/*
default is current date when picker created.
*/
datePicker.date = [NSDate date];
[datePicker setDate:[NSDate dateWithTimeIntervalSinceNow:60*60*26] animated:YES];
// 设置最小的时间
/*
default is nil
*/
datePicker.minimumDate = [NSDate dateWithTimeIntervalSince1970:0];
// 设置最大时间
/*
default is nil
*/
datePicker.maximumDate = [NSDate dateWithTimeIntervalSinceNow:60*60*24*7];
// 设置可以调整的最小时间间隔(分钟)
/*
interval must be evenly divided into 60. default is 1. min is 1, max is 30
*/
datePicker.minuteInterval = 2;
// 设置倒计时时间值(秒)
/*
default is 0.0. limit is 23:59 (86,399 seconds)。必须为 60 的整数倍,比如设置为 100,值自动变为 60
*/
datePicker.countDownDuration = 60*60;
// 添加点击触发事件
[datePicker addTarget:self action:@selector(datePickerChanged:) forControlEvents:UIControlEventValueChanged];
标签:mini return picker 整数 make get enter cti when
原文地址:https://www.cnblogs.com/CH520/p/9413484.html