博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIKit 框架之UIDatePicker
阅读量:6983 次
发布时间:2019-06-27

本文共 2479 字,大约阅读时间需要 8 分钟。

////  ViewController.m//  UIDatePicker////  Created by City--Online on 15/5/19.//  Copyright (c) 2015年 XQB. All rights reserved.// #import "ViewController.h" @interface ViewController ()@property(nonatomic,strong) UIDatePicker *datePicker;@end @implementation ViewController - (void)viewDidLoad {    [super viewDidLoad];         //高度宽度系统设置好的 只需设置左上角坐标    _datePicker=[[UIDatePicker alloc]initWithFrame:CGRectMake(20, 100, 100, 200)];//    typedef NS_ENUM(NSInteger, UIDatePickerMode) {//        UIDatePickerModeTime,           (e.g. 6 | 53 | PM)  小时分钟 AM/PM//        UIDatePickerModeDate,           (e.g. November | 15 | 2007) 年月日//        UIDatePickerModeDateAndTime,    (e.g. Wed Nov 15 | 6 | 53 | PM) 年月日小时分钟 AM/PM//        UIDatePickerModeCountDownTimer, (e.g. 1 | 53)  小时分钟//    };    //时间模式 显示的样式    _datePicker.datePickerMode=UIDatePickerModeDate;         //设置DatePicker的地区,即设置DatePicker显示的语言    //跟踪所有可用的地区,取出想要的地区    NSLog(@"%@",[NSLocale availableLocaleIdentifiers]);//    NSLocale *locale=[[NSLocale alloc ]initWithLocaleIdentifier:@"zh_Hans_CN"];    NSLocale *locale=[[NSLocale alloc ]initWithLocaleIdentifier:@"en_SC"];    _datePicker.locale=locale;         //设置日历默认当天    _datePicker.calendar=[NSCalendar currentCalendar];         //设置时区    _datePicker.timeZone=[NSTimeZone localTimeZone];         //设置显示时间    _datePicker.date=[NSDate date];         //设置最小时间 10天前    _datePicker.minimumDate=[[NSDate date] dateByAddingTimeInterval:-60*60*24*10];         //设置最大时间 10天后    _datePicker.maximumDate=[[NSDate date]dateByAddingTimeInterval:60*60*24*10];     //    设置DatePicker的倒计时间.//    //    1.设置日期选择的模//    [self.datePicker setDatePickerMode:UIDatePickerModeCountDownTimer];//    2.设置倒计时的时长//    注意:设置倒计时时长需要在确定模式之后指定//    // 倒计时的时长,以秒为单位//    [self.datePicker setCountDownDuration:10 * 60];         //将分钟表盘设置为以不同的时间间隔来显示分钟,前提是该间隔要能够让60整除。默认间隔是一分钟。如果要使用不同的间隔,需要改变 minuteInterval属性:    _datePicker.minuteInterval=120;         //UIDatePicker是UIControl,可以为其增加事件响应    [_datePicker addTarget:self action:@selector(dateChanged) forControlEvents:UIControlEventValueChanged];    _datePicker.backgroundColor=[UIColor clearColor];    [self.view addSubview:_datePicker];     }-(void)dateChanged{    NSLog(@"%@",_datePicker.date);    sleep(10);    //表盘滚动到指定日期    [_datePicker setDate:[[NSDate date] dateByAddingTimeInterval:-60*60*24*1] animated:YES];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.} @end

转载地址:http://haxpl.baihongyu.com/

你可能感兴趣的文章
Nginx与Serssion一致性问题
查看>>
社会化工程攻击针对目标不再仅限最终用户
查看>>
Hadoop源码分析HDFS ClientProtocol——getBlockLocations
查看>>
AndroidWidget实践 --- EverydayTips开发(6)
查看>>
mysql 随机查询数据
查看>>
CodeIgniter学习笔记一
查看>>
workspace-project-target关系与解耦工程结构总结
查看>>
EhCache的配置
查看>>
Linux 设置时区
查看>>
在maven中引用github上的资源
查看>>
4、Angular JS 学习笔记 – 创建自定义指令 [翻译中]
查看>>
Flex手机开发-退出应用程序
查看>>
常用的7大排序算法汇总
查看>>
数字转化成时分秒(二)
查看>>
Golang通过syscall调用win32的Api
查看>>
阿里云Redis (安装包安装篇)
查看>>
Spring Bean的装配(非XML文件方式)
查看>>
100万“愤怒的小鸟”:中国手机开发者生存调查
查看>>
centos 6.3 x86_64安装32位JDK的问题
查看>>
springmvc学习笔记(17)-上传图片
查看>>