Created
February 18, 2014 19:40
-
-
Save samdmarshall/9078370 to your computer and use it in GitHub Desktop.
This file contains 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 characters
@implementation NSView(Additions) | |
- (void)addSubviewAndUpdateConstraints:(NSView *)view { | |
[self addSubview:view]; | |
view.translatesAutoresizingMaskIntoConstraints = NO; | |
for (NSString *string in @[@"H:|[view]|", @"V:|[view]|"]) { | |
NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:string options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]; | |
[view.superview addConstraints:constraints]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment