Arnol
Arnol

Reputation: 2147

Cocoa - Date picker control

Could someone tell me what is this control?

enter image description here

I cannot find it in the IB. The control has a textfield interface. Click on one of its date components will show a calendar popup.

Thank you!

Upvotes: 2

Views: 2210

Answers (4)

T.Jurko
T.Jurko

Reputation: 162

As I see it's probably ExpandingDatePicker CocoaPod. Find more details about this control at https://github.com/fpotter/ExpandingDatePicker .

Upvotes: 1

Marek H
Marek H

Reputation: 5566

Actually it's a standard control with a custom NSPanel ( IIDatePickerPanel ) drawn above NSDatePicker. The IIDatePickerPanel has contentView with 2 instances of custom NSDatePicker (IIClosableDatePicker, IIDatePicker)

The only magic is the drawing illusion of the contentView IIDatePickerPanelContentView.

PS: The panel window is initialised with the datepicker view so it match the frame in case the window gets closed

(lldb) po [0x7fe5f711b670 contentView]
<IIDatePickerPanelContentView: 0x600002e6eaa0>

(lldb) po [[0x7fe5f711b670 contentView] _subtreeDescription]
[   A      w   ] h=--- v=--- IIDatePickerPanelContentView 0x600002e6eaa0 f=(0,0,139,169) b=(-) => <_NSViewBackingLayer: 0x6000017911a0>
  [   A          ] h=--- v=--- IIClosableDatePicker 0x600002e69290 "Wednesday, 13 May 2020 at 12:00:00 Malaysia Time" f=(0,0,139,148) b=(-)
  [   A          ] h=--- v=--- IIDatePicker 0x600002e58000 "Wednesday, 13 May 2020 at 12:00:00 Malaysia Time" f=(0,148,81,21) b=(-)
A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), V=needsVibrancy (v=allowsVibrancy), #=has surface

(lldb) po [0x600002e69290 superclass]
NSDatePicker

(lldb) po [0x600002e58000 superclass]
NSDatePicker

Upvotes: 0

Sudhir Bhagat
Sudhir Bhagat

Reputation: 137

I also suffered with same problem, but got answer :

There is no seperate control for this, This same NSDatePicker that u are using previously, But need to set following property in IB:

Set Style of NSDatePicker : Graphical, So that NsDatePicker will convert to graphical that u want.

Upvotes: 0

Daniel Farrell
Daniel Farrell

Reputation: 9740

Drag out a date picker and change the style to graphical, this will get you most of the way. But this is a custom view in the way it pops up. You might want to look into displaying this in a NSPopOver, seems to be closest option.

Upvotes: 3

Related Questions