Skip to content

Instantly share code, notes, and snippets.

@kartikshah
Created January 6, 2014 04:03
Show Gist options
  • Save kartikshah/8278046 to your computer and use it in GitHub Desktop.
Save kartikshah/8278046 to your computer and use it in GitHub Desktop.
AutoLayout Constraints Blog - Landscape Constraints
[_containerView addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"|-[_leftOrTopView]-[_rightOrBottomView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_leftOrTopView, _rightOrBottomView)]];
[_containerView addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_leftOrTopView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_leftOrTopView)]];
[_containerView addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_rightOrBottomView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_rightOrBottomView)]];
[_containerView addConstraint: [NSLayoutConstraint constraintWithItem:_leftOrTopView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:_rightOrBottomView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0 ]];
[_containerView addConstraint: [NSLayoutConstraint constraintWithItem:_leftOrTopView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:_rightOrBottomView attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment