coolly coolly - 1 year ago 174
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download