组件_DatePicket
/**
1.初始化
2.设置选择控件的格式
3.设置日期选择控件的地区
4.监听日期选择控件数值变化
**/
UIDatePicker *datePicker = [[UIDatePicker alloc]init];
[datePicker setDatePickerMode:UIDatePickerModeDate];
NSLog(@"%@", [NSLocale availableLocaleIdentifiers]);
[datePicker setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_Hans_CN"]];
[datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
//将字符串转化成日期。
NSString *dateString = @"1949-10-1";
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [formatter dateFromString:dateString];
[datePicker setDate:date];
[xxText setInputView:datePicker];
/将日期转换成字符串
NSDate *date = datePicker.date;
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString *dateString = [formatter stringFromDate:date];