0

I want to add a NSDatePicker in the sidebar of my app, to help select dates. The standard NSDatePicker only seems to come in a single size, and doesn't seem to be resizable. I've dropped the NSDatePicker component into a xib file, and added auto-layout constraints, but they don't seem to work. Is there a way to make them respond to auto-layout and be resizable? Or should I be looking for 3rd-party frameworks to integrate with (if so, any recommendations)?

Z S
  • 7,039
  • 12
  • 53
  • 105

1 Answers1

0

Wrap the date picker in a superview. Set the bounds of the superview and the date picker will stretch.

class MyScaledView: NSView {

    @IBOutlet weak var wrappedSubView: NSView! // date picker
    
    override func layout() {
        super.layout()
        bounds = wrappedSubView.frame
    }
    
}

Constrain the location of the date picker but not its size. For example add constraints for leading and bottom space.

Willeke
  • 14,578
  • 4
  • 19
  • 47