Skip to content

Instantly share code, notes, and snippets.

@sebk
Created September 29, 2013 08:48
Show Gist options
  • Save sebk/6750587 to your computer and use it in GitHub Desktop.
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
[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