UIDatePicker的使用
来源:互联网 发布:网络维护基础知识 编辑:程序博客网 时间:2024/05/18 09:02
@property (nonatomic,strong)UIView *background;
@property (nonatomic,strong)UIView *pickerBgView;
@property (nonatomic,strong)UIDatePicker *datePicker;
_background = [[UIViewalloc]init];
_background.frame =CGRectMake(0,0,WEIDTH,HEIGHT);
_background.backgroundColor = [UIColorblackColor];
_background.alpha =0.5;
_background.hidden=NO;
[self.navigationController.viewaddSubview:_background];
_pickerBgView = [[UIViewalloc]init];
_pickerBgView.frame =CGRectMake(0,HEIGHT - 250,WEIDTH,200);
_pickerBgView.backgroundColor = [UIColorwhiteColor];
_pickerBgView.hidden=NO;
[self.navigationController.viewaddSubview:_pickerBgView];
UIButton *cancelBtn = [[UIButtonalloc]init];
cancelBtn.frame =CGRectMake(10,10,60,20);
[cancelBtn setTitle:@"取消"forState:UIControlStateNormal];
[cancelBtn setTitleColor:[UIColorgrayColor]forState:UIControlStateNormal];
[cancelBtn addTarget:selfaction:@selector(cancelBtnClick)forControlEvents:UIControlEventTouchUpInside];
[_pickerBgViewaddSubview:cancelBtn];
UIButton *confirmBtn = [[UIButtonalloc]init];
confirmBtn.frame =CGRectMake(WEIDTH -70,10,60,20);
[confirmBtn setTitle:@"确定"forState:UIControlStateNormal];
[confirmBtn setTitleColor:[UIColororangeColor]forState:UIControlStateNormal];
confirmBtn.tag =1;
[confirmBtn addTarget:selfaction:@selector(confirmBtnClick)forControlEvents:UIControlEventTouchUpInside];
[_pickerBgViewaddSubview:confirmBtn];
_datePicker=[[UIDatePickeralloc]initWithFrame:CGRectMake(0,50,WEIDTH, 150)];
[_datePickersetTimeZone:[NSTimeZonesystemTimeZone]];
[_datePickeraddTarget:selfaction:@selector(datePickerChangeValue:)forControlEvents:UIControlEventValueChanged];
[_datePickersetDatePickerMode:UIDatePickerModeDateAndTime];
[_pickerBgViewaddSubview:_datePicker];
-(void)datePickerChangeValue:(UIDatePicker*)pickerView{
NSDate *date = pickerView.date;
NSDateFormatter *dateFormatter = [[NSDateFormatteralloc]init];
[dateFormatter setDateFormat:@"yyyy年-MM月-dd日"];
_currentDay = [dateFormatterstringFromDate:date];
NSLog(@"--%@",_currentDay);
}
-(void)cancelBtnClick{
_background.hidden=YES;
_pickerBgView.hidden=YES;
}
-(void)confirmBtnClick{
_background.hidden=YES;
_pickerBgView.hidden=YES;
NSLog(@"--%@",_datePicker.date);
}
- UIDatePicker的使用
- UIDatePicker的使用
- UIDatePicker 的使用
- UIDatePicker的使用
- UIDatePicker的使用
- UIDatePicker的简单使用
- UIDatePicker的使用
- UIDatePicker的使用
- UIDatePicker的使用
- UIDatePicker的使用
- UIDatePicker的使用
- UIPickView与UIDatePicker的使用
- swift中UIDatePicker的使用
- swift中UIDatePicker的使用
- iOS UIDatePicker的使用详情
- IOS UIDatePicker控件的简单使用
- iOS开发 UIDatePicker的创建与使用
- IOS 日期选择器 UIDatePicker的使用
- 第八周项目一 顺序串
- Docker 简介
- IntelliJ IDEA 创建 android项目(2)
- 爬虫知识点(scrapy_redis分布式爬虫系统)
- Android Material Design AppBarLayout使用
- UIDatePicker的使用
- idea
- J2EE分布式架构 dubbo+springmvc+mybatis+ehcache+redis分布式架构
- shell基础
- 第八周【项目2
- Linux 基础命令(二)
- CSS特殊字符表
- # 设计模式之----命令模式
- angular4 模块懒加载