Created
August 2, 2019 07:35
-
-
Save th3m477/95355948cfec064084b65b06c0c2cd6d to your computer and use it in GitHub Desktop.
Constraint shortcuts
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 NSLayoutAnchor { | |
@objc @discardableResult func eq(_ anchor: NSLayoutAnchor, _ constant: CGFloat = 0.0) -> NSLayoutConstraint { | |
let c = constraint(equalTo: anchor, constant: constant) | |
c.isActive = true | |
return c | |
} | |
@objc @discardableResult func lte(_ anchor: NSLayoutAnchor, _ constant: CGFloat = 0.0) -> NSLayoutConstraint { | |
let c = constraint(lessThanOrEqualTo: anchor, constant: constant) | |
c.isActive = true | |
return c | |
} | |
@objc @discardableResult func gte(_ anchor: NSLayoutAnchor, _ constant: CGFloat = 0.0) -> NSLayoutConstraint { | |
let c = constraint(greaterThanOrEqualTo: anchor, constant: constant) | |
c.isActive = true | |
return c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment