Skip to content

Instantly share code, notes, and snippets.

@irskep
Created December 8, 2015 18:11
Show Gist options
  • Save irskep/06822ca3f09898d42664 to your computer and use it in GitHub Desktop.
Save irskep/06822ca3f09898d42664 to your computer and use it in GitHub Desktop.
/*
self.view.addConstraints(NSLayoutConstraint.hip_constraintsWithVisualFormats(
["H:|[label]|", "V:|[label]|"], options: [], metrics: nil, views: ["label": label]))
*/
extension NSLayoutConstraint {
class func hip_constraintsWithVisualFormats(
formats: [String], options: NSLayoutFormatOptions, metrics: [String: AnyObject]?, views: [String: AnyObject])
-> [NSLayoutConstraint]
{
var constraints: [NSLayoutConstraint] = []
for format in formats {
constraints += NSLayoutConstraint.constraintsWithVisualFormat(
format, options: options, metrics: metrics, views: views)
}
return constraints
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment