UIDatePicker swift
//
// ViewController.swift
// UILabelTest
//
// Created by mac on 15/6/23.
// Copyright (c) 2015年 fangyuhao. All rights reserved.
//
import UIKit
class ViewController: UIViewController{
@IBOutlet weak var dpicker: UIDatePicker!
@IBOutlet weak var btnshow: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
println(dpicker.locale!.localeIdentifier)
println(dpicker.calendar.calendarIdentifier)
var date = dpicker.date
println(date.descriptionWithLocale(dpicker.locale))
}
@IBAction func showClicked(sender: UIButton) {
var date = dpicker.date
//创建一个日期格式器
var dformatter = NSDateFormatter()
dformatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
var datestr = dformatter.stringFromDate(date)
var message = "您旋转的日期和时间是:\(datestr)"
//创建一个警告框
let alertView = UIAlertView()
alertView.title = "当前日期和时间"
alertView.message = message
alertView.addButtonWithTitle("确定")
alertView.show()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}