Last active
January 20, 2016 09:56
-
-
Save vahotm/f2516749db637f7e6b12 to your computer and use it in GitHub Desktop.
Snippet for constraints in Visual Format Language, that center view vertically and horizontally in its superview.
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
// Vertical center in container | |
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[superview]-(<=1)-[view]" | |
options:NSLayoutFormatAlignAllCenterY | |
metrics:nil | |
views:viewDict]]; | |
// Horizontal center in container | |
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[superview]-(<=1)-[view]" | |
options:NSLayoutFormatAlignAllCenterX | |
metrics:nil | |
views:viewDict]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment