Created
August 15, 2012 02:56
Revisions
-
Justin Williams created this gist
Aug 15, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ NSView *contentView = [self.window contentView]; self.button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 50.0f)]; [self.button setTranslatesAutoresizingMaskIntoConstraints:NO]; [self.button setTitle:@"This is a test button"]; [self.button setBordered:YES]; [contentView addSubview:self.button]; NSButton *button = self.button; NSDictionary *views = NSDictionaryOfVariableBindings(contentView, button); [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[button(>=50)]" options:NSLayoutFormatAlignAllTop metrics:nil views:views]]; [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[button(>=50)]-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:views]]; [contentView addConstraints:@[ [NSLayoutConstraint constraintWithItem:self.button attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]];