Created
August 12, 2014 00:13
-
-
Save yokomotod/f2c043918855f52447e1 to your computer and use it in GitHub Desktop.
[AutoLayout] Visual Format Languageが生成するNSLayoutConstraintを全手動で再現 ref: http://qiita.com/yokomotod/items/075ad42fe3e8fa02dd92
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
// Constraint(制約)を追加 | |
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-40-[view1(==240)]-20-[view2(==240)]-40-|" | |
options:0 | |
metrics:0 | |
views:NSDictionaryOfVariableBindings(view1, view2)]]; |
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
[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