CocoaPods trunk is moving to be read-only. Read more on the blog, there are 11 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Mar 2018 |
| SPMSupports SPM | ✗ |
Maintained by Andres Cecilia Luque.
Yet, another autolayout framework. Why is this different?
In iOS9 Apple introduced StackViews as an easier, safer, more effective and more flexible way of configuring the layout (they are great ;P). But, after using them for a long time I find them too verbose, requiring several lines of code when I want to perform a simple layout change that is a bit more elaborated than usual. In the end, when the view layout grows in length and complexity, such an amount of unordered lines of code is prone to bugs, and difficult to read.
This framework makes exclusive use of StackViews for configuring the layout: basically you can see it as syntactic sugar for StackView based layouts. the benefits are:
hFixed corresponds to views with height constraint (in red color). hwFixed corresponds to views with height and width constraints (in orange color):
UIStackView(hFixedView1, axis: .vertical, spacing: 10)
.nest(label, alignment: .center)
.nest(alignment: .center) {
$0.nest(hwFixedView1, hwFixedView2, axis: .horizontal, alignment: .top)
}
.nest(hFixedView2, margins: [.left + .right: 30]) // This way of setting the margins is provided by the framework SugarEdges
.snapEdges(in: contentView)The result:
To run the example project, clone the repo, and open the workspace found under the Example folder with Xcode.
In order to easily set the margins when using NestLayout, it is recommended (but not mandatory) to also install SugarEdges.
NestLayout is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'NestLayout'Andrés Cecilia Luque (acecilia), [email protected]
NestLayout is available under the MIT license. See the LICENSE file for more info.