Last active
March 12, 2017 01:04
-
-
Save efremidze/13c11819e83cb718834c7f212992f01f to your computer and use it in GitHub Desktop.
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
protocol Constrainable {} | |
extension Constrainable where Self: UIView { | |
@discardableResult | |
func constrain(constraints: (Self) -> [NSLayoutConstraint]) -> [NSLayoutConstraint] { | |
let constraints = constraints(self) | |
self.translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activate(constraints) | |
return constraints | |
} | |
} | |
extension UIView: Constrainable {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment