Skip to content

Instantly share code, notes, and snippets.

@yokomotod
Created August 12, 2014 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yokomotod/f2c043918855f52447e1 to your computer and use it in GitHub Desktop.
Save yokomotod/f2c043918855f52447e1 to your computer and use it in GitHub Desktop.
[AutoLayout] Visual Format Languageが生成するNSLayoutConstraintを全手動で再現 ref: http://qiita.com/yokomotod/items/075ad42fe3e8fa02dd92
// Constraint(制約)を追加
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-40-[view1(==240)]-20-[view2(==240)]-40-|"
options:0
metrics:0
views:NSDictionaryOfVariableBindings(view1, view2)]];
[self.scrollView addConstraint:
[NSLayoutConstraint constraintWithItem:view1
attribute:NSLayoutAttributeLeft
relatedBy:NSLayoutRelationEqual
toItem:self.scrollView
attribute:NSLayoutAttributeLeft
multiplier:1.0
constant:40]];
[self.scrollView addConstraint:
[NSLayoutConstraint constraintWithItem:view1
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:240]];
[self.scrollView addConstraint:
[NSLayoutConstraint constraintWithItem:view2
attribute:NSLayoutAttributeLeft
relatedBy:NSLayoutRelationEqual
toItem:view1
attribute:NSLayoutAttributeRight
multiplier:1.0
constant:20]];
[self.scrollView addConstraint:
[NSLayoutConstraint constraintWithItem:view2
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:240]];
[self.scrollView addConstraint:
[NSLayoutConstraint constraintWithItem:view2
attribute:NSLayoutAttributeRight
relatedBy:NSLayoutRelationEqual
toItem:self.scrollView
attribute:NSLayoutAttributeRight
multiplier:1.0
constant:40]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment