Skip to content
An NSDatePicker that expands to show a graphical calendar view when focused.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example ExpandingDatePicker requires datePickerStyle of .textField Apr 6, 2019
ExpandingDatePicker ExpandingDatePicker requires datePickerStyle of .textField Apr 6, 2019
.gitignore
.travis.yml fixing travis build Mar 30, 2019
ExpandingDatePicker.podspec bump to 1.0.1 Apr 4, 2019
LICENSE First pass at framework and demo app. Mar 30, 2019
README.md Update README.md Apr 11, 2019
_Pods.xcodeproj Initial commit Mar 29, 2019
screenshot.gif updating video Apr 6, 2019

README.md

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.

You can’t perform that action at this time.