标签:uidatepicker
<span style="background-color: rgb(51, 204, 255);">// // NSDatePickerViewController.m // NSDatePicker // // Created by xiaoyao on 15/4/20. // Copyright (c) 2015年 lijien. All rights reserved. // #import "NSDatePickerViewController.h" @interface NSDatePickerViewController () { UIDatePicker *_datePicker; UILabel *_dateLabel; } @end @implementation NSDatePickerViewController - (void)viewDidLoad { [super viewDidLoad]; CGFloat width = self.view.frame.size.width; CGFloat height = self.view.frame.size.height; _datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 200, width, height)]; [self.view addSubview:_datePicker]; // 选择datePicker的模式 // 有三种模式 日期模式、时间日期模式、时间模式、计数器倒计时模式 _datePicker.datePickerMode = UIDatePickerModeDate; NSDate *date = _datePicker.date; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"YYYY-MM-DD HH:mm:ss"]; _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 400, width, height)]; _dateLabel.textColor = [UIColor lightGrayColor]; _dateLabel.text = [dateFormatter stringFromDate:date]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </span>
标签:uidatepicker
原文地址:http://blog.csdn.net/u010606986/article/details/45147479