coolly coolly - 4 months ago 70x
iOS Question

How to create and subclass custom UIPickerView which shows only date, in swift?

In swift, how to create custom picker view by subclass UPickerView, so it shows only date picker? Couldn't find answer for this. Any kind of help is appreciated.


to be able to instantiate the picker from code AND storyboard you have to override both initializers like this:

class DatePicker: UIDatePicker {
    override init(frame: CGRect) {
        super.init(frame: frame)

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

    private func sharedInit() {
        datePickerMode = .Date