Created
January 22, 2015 19:54
-
-
Save davelyon/27f5efce00bb36dbe2ad to your computer and use it in GitHub Desktop.
Swift helpers for multiple visual constraints
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
extension NSLayoutConstraint { | |
public class func visualConstraintsWithMetrics(metrics: [String : CGFloat], views: [String : UIView], options: NSLayoutFormatOptions = nil, strings: String...) -> [NSLayoutConstraint] { | |
return map(strings, { string in | |
return NSLayoutConstraint.constraintsWithVisualFormat(string, options: options, metrics: metrics, views: views) as [NSLayoutConstraint] | |
}).reduce([], +) | |
} | |
public class func visualConstraintsWithViews(views: [String : UIView], options: NSLayoutFormatOptions = nil, strings: String...) -> [NSLayoutConstraint] { | |
return map(strings, { string in | |
return NSLayoutConstraint.constraintsWithVisualFormat(string, options: nil, metrics: nil, views: views) as [NSLayoutConstraint] | |
}).reduce([], +) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment