CocoaPods trunk is moving to be read-only. Read more on the blog, there are 16 months to go.

LayoutSugar 1.0.1

LayoutSugar 1.0.1

Maintained by Matt Provost.



  • By
  • Matt Provost

LayoutSugar

Version License Platform

LayoutSugar is the layout framework stripped from the Material project. There are some changes to the actual code, and most of the documentation has been rewritten, but for the most part, this works like it does in Material. The reason it got put into a separate project is because I wanted to take advantage of the nice layout capabilities, but lost my use for the other components added by Material.

Installation

LayoutSugar is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LayoutSugar'

Example

To use LayoutSugar, your code might look something like so:

view.layout(subview)
    .top(20)
    .leading(10)
    .trailing(10)
    .bottom(5)

You can also set thing like multipliers and priorities:

view.layout(subview)
    .top(20).multiplier(2).priority(500)

Views can also be laid out based on specific anchors and using specific relationships:

view.layout(subview)
    .top(otherView.bottom, 20, >=)

All of this code should be located when the view is first loaded, which would be in the view controller's viewDidLoad method.

Information

Author

Matt Provost, [email protected]

License

LayoutSugar is available under the MIT license. See the LICENSE file for more info.

Credits

Full credit goes to CosmicMind for making Material. Most of the code in this project is derived from that repository.