Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snippet for constraints in Visual Format Language, that center view vertically and horizontally in its superview.
// 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
You can’t perform that action at this time.