Configure the window in Interface Builder to contain the NSBox and set limits to the default value from all sides. Then add {IBOutlet NSBox *box;} to AppDelegate.h , and in IB connect the outlet to the box. In AppDelegate.m add the following to applicationDidFinishLaunching and run the code. I think this is what you need. If you add your restrictions programmatically, be sure to add enough restrictions on height and width to indicate what you want. Just add this restriction in addition to other restrictions.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { box.translatesAutoresizingMaskIntoConstraints = NO; [box addConstraint: [NSLayoutConstraint constraintWithItem:box attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:box attribute:NSLayoutAttributeHeight multiplier:1 constant:0]]; }
source share