iOS UIDatePicker设置允许最小日期、最大日期范围
来源:互联网 发布:雅思作文知乎simon 编辑:程序博客网 时间:2024/04/30 05:36
设置UIDatePicker的允许最大时间、最小时间:
self.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, CGRectGetWidth(self.frame), 216)];datePicker.datePickerMode = UIDatePickerModeDate;datePicker.locale = [NSLocale localeWithLocaleIdentifier:@"zh"];datePicker.backgroundColor = [UIColor whiteColor];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];NSDate *currentDate = [NSDate date];NSDateComponents *comps = [[NSDateComponents alloc] init];[comps setYear:10];//设置最大时间为:当前时间推后十年NSDate *maxDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];[comps setYear:-10];//设置最小时间为:当前时间前推十年NSDate *minDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
[datePicker setMaximumDate:maxDate];[datePicker setMinimumDate:minDate];
1 0
- iOS UIDatePicker设置允许最小日期、最大日期范围
- UIDatePicker 基本设置-显示已经选择的日期 并设置最大、最小日期
- UIDatePicker的用法:最小日期和最大日期
- ios设置UIDatePicker日期为中文格式
- iOS日期选择器(UIDatePicker)
- iOS 时间/ 日期选择器 UIDatePicker
- 设置DatePicker的最大最小日期
- datePicker时间控件最大日期、最小日期设置
- IOS 日期选择器 UIDatePicker的使用
- Unity调用IOS时间日期控件UIDatePicker
- iOS中UIDatePicker显示中文日期
- iOS自定义UIDatepicker日期选择器视图
- 设置日期控件可选范围
- Android DatePickerDialog 设置日期范围
- 日期选择UIDatePicker相关
- UIDatePicker日期选取-ios7
- 日期选择器UIDatePicker
- 日期选择UIDatePicker相关
- 这就是王者!孙杨用冠军回击污蔑
- 类
- 创建全屏右滑返回上一级界面
- 安卓学习笔记---【Android】获取手机的基本信息
- spring ioc(转载)
- iOS UIDatePicker设置允许最小日期、最大日期范围
- LoadRunner常用知识点——集合点设置
- 训练第五周之只有五行的Floyd算法
- VS服务器资源管理器添加Mysql数据源
- Lightoj 1282 Leading and Trailing(前三后三位,学习fmod())
- android 实现淘宝消息滚动条
- 使用grunt压缩,合并前端代码
- POJ-----1745Divisibility
- hdu1010 Tempter of the Bone