1、datePicker
又名:日期选择器。
2、效果图:
做的比较简陋。
3、表示层结构
控件有:
4、源码
语言:swift2.2
import UIKit class ViewController: UIViewController { @IBOutlet weak var datePicker: UIDatePicker! @IBOutlet weak var lbl_currentDate: UILabel! override func viewDidLoad() { super.viewDidLoad(); lbl_currentDate.adjustsFontSizeToFitWidth = true; } /// datePicker事件 @IBAction func OnChangeDate(sender: AnyObject) { let date = datePicker.date; let dateFormat = NSDateFormatter(); /// 日期格式 dateFormat.dateFormat = "YYYY年MM月dd日 HH:MM"; /// 显示当前日期 lbl_currentDate.text = "日期:" + String(dateFormat.stringFromDate(date)); } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }原文链接:https://www.f2er.com/swift/323706.html