An expressive and extensible DSL for creating Auto Layout constraints and defining declarative layouts.
// Creating inactive constraints (save and activate/manipulate later) let constraints = view.makeConstraints( .center(), .size(CGSize(width: 100, height: 100)) )
// Creating active constraints view.applyConstraints( .center(), .size(CGSize(width: 100, height: 100)) )
applyConstraints operate on both
UILayoutGuide. All constraints that are setup up in relation to other items may also be either
button.applyConstraints( .center(in: view.safeAreaLayoutGuide), // relating to a `UILayoutGuide` .relativeSize(of: otherButton) // relating to a `UIView` )
Constraints that are related to another item default to the receiver’s parent view. Therefore, the following two examples are identical:
// Preferred button.applyConstraints( .center() )
// Not-preferred button.applyConstraints( .center(in: button.superview) )
false on the receiver of the
Layout has the ability to add debug identifiers to all constraints that include the file, function, and line number of where the constraint was created. If you are having trouble with ambiguous constraints, you can enable these identifiers like this:
// Call this in your AppDelegate ConstraintGroup.debugConstraints = true
Layout has not yet been published as a CocoaPod, but you may still use it.
To integrate Layout into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'Layout', :git => 'firstname.lastname@example.org:/noremac/Layout.git', :tag => '0.0.2'
To integrate Layout into your Xcode project using Carthage, specify it in your Cartfile:
carthage update to build the framework and drag the built
Layout.framework into your Xcode project.
This code and tool is under the MIT License. See
LICENSE file in this repository.