UIDatePicker

UIDatePicker.playground is an starting point to experiment with UIDatePicker in an interactive playground:

UIView

import UIKit
import PlaygroundSupport

class DatePickerViewController : UIViewController {

    override func loadView() {

        // UI
        view = UIView()
        view.backgroundColor = .white

        let datePicker = UIDatePicker()
        datePicker.datePickerMode = .date

        view.addSubview(datePicker)

        // Layout

        datePicker.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            datePicker.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
            datePicker.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
            datePicker.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
        ])
        
        self.view = view
    }
    
}

PlaygroundPage.current.liveView = DatePickerViewController()
iOS training Next iOS training: 24. - 28. Juni 2019, Frankfurt am Main
Contact About me · Contact