Created
January 10, 2019 00:29
-
-
Save xocialize/a6d8dba3a09daad54444e36901890738 to your computer and use it in GitHub Desktop.
VFL Centering
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
// Center horizontally | |
var constraints = NSLayoutConstraint.constraintsWithVisualFormat( | |
"V:[superview]-(<=1)-[label]", | |
options: NSLayoutFormatOptions.AlignAllCenterX, | |
metrics: nil, | |
views: ["superview":view, "label":label]) | |
view.addConstraints(constraints) | |
// Center vertically | |
constraints = NSLayoutConstraint.constraintsWithVisualFormat( | |
"H:[superview]-(<=1)-[label]", | |
options: NSLayoutFormatOptions.AlignAllCenterY, | |
metrics: nil, | |
views: ["superview":view, "label":label]) | |
view.addConstraints(constraints) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment