Created
September 29, 2013 08:48
-
-
Save sebk/6750587 to your computer and use it in GitHub Desktop.
Subview equals width and height of superview (I always forget how to do such things in code) with autolayout
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 characters
[subview setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
[self.view addConstraints:[NSLayoutConstraint | |
constraintsWithVisualFormat:@"H:|-0-[subview]-0-|" | |
options:NSLayoutFormatDirectionLeadingToTrailing | |
metrics:nil | |
views:NSDictionaryOfVariableBindings(subview)]]; | |
[self.view addConstraints:[NSLayoutConstraint | |
constraintsWithVisualFormat:@"V:|-0-[subview]-0-|" | |
options:NSLayoutFormatDirectionLeadingToTrailing | |
metrics:nil | |
views:NSDictionaryOfVariableBindings(subview)]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment