Skip to content

fpotter/ExpandingDatePicker

Repository files navigation

ExpandingDatePicker

Screenshot

CI Status Version License Platform

ExpandingDatePicker is a textual date picker that will expand to show a graphical date picker beneath it when focused. It has the same styling as the expandable date picker Apple uses in Calendar.app.

Installation

ExpandingDatePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ExpandingDatePicker'

Usage (Programmatic)

ExpandingDatePicker extends NSDatePicker so the API is the same. Only catch is that it only works for year/month/day elements, in single picker mode and in the textField style.

import ExpandingDatePicker



let datePicker = ExpandingDatePicker(frame: .zero)
// Required settings...
datePicker.datePickerElements = .yearMonthDay
datePicker.datePickerMode = .single
datePicker.datePickerStyle = .textField
datePicker.sizeToFit()



view.addSubview(datePicker)

Usage (Interface Builder)

Use the Library to add a Date Picker to your view. In the Identity Inspector panel, set the custom class to ExpandingDatePicker.

Requirements

Deployment target of macOS 10.10+, though it has only been tested on 10.14.

Known Issues

  • When the field expands to show the graphical date picker, you'll notice that the traffic lights in your app's window will turn gray. The expansion is shown in an NSPanel (a special kind of NSWindow), and when that panel temporarily becomes the app's key window, the traffic lights go dark. Calendar.app's version of this expanded date picker doesn't have this problem because they use a private API.

Author

Fred Potter, fpotter@gmail.com

License

ExpandingDatePicker is available under the MIT license. See the LICENSE file for more info.

About

An NSDatePicker that expands to show a graphical calendar view when focused.

Resources

License

Stars

Watchers

Forks

Packages

No packages published