Created
October 23, 2022 01:00
-
-
Save cjnevin/08e31e5ee307df918ddb9232bbf7bd47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public protocol ConstraintBuilding { | |
| var anchorable: Anchorable { get } | |
| func build( | |
| _ anchor: Anchor, | |
| constant: CGFloat, | |
| multiplier: CGFloat | |
| ) -> ConstraintBuilder | |
| } | |
| extension ConstraintBuilding { | |
| public func leading(_ constant: CGFloat = 0, multiplier: CGFloat = 1) -> ConstraintBuilder { | |
| build(anchorable.anchor(.leading), constant: constant, multiplier: multiplier) | |
| } | |
| public func trailing(_ constant: CGFloat = 0, multiplier: CGFloat = 1) -> ConstraintBuilder { | |
| build(anchorable.anchor(.trailing), constant: constant, multiplier: multiplier) | |
| } | |
| public func top(_ constant: CGFloat = 0, multiplier: CGFloat = 1) -> ConstraintBuilder { | |
| build(anchorable.anchor(.top), constant: constant, multiplier: multiplier) | |
| } | |
| public func bottom(_ constant: CGFloat = 0, multiplier: CGFloat = 1) -> ConstraintBuilder { | |
| build(anchorable.anchor(.bottom), constant: constant, multiplier: multiplier) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment