I’ve mentioned a number of libraries providing alternatives to auto layout, most recently EZLayout inspired by the UIStackView API.
Here’s an open source library submitted by Taiki Suzuki called mister Fusion providing a swift AutoLayout DSL.
The key advantage of MisterFusion is the extremely clear, but concise syntax. MisterFusion is written in Swift, but can be used in both Swift and Objective-C with usage examples in both languages provided.
This code snippet from the readme showing how concise the MisterFusion syntax is:
self.view.addLayoutSubview(view, andConstraints:
view.Top |+| 10,
view.Right |-| 10,
view.Left |+| 10,
view.Bottom |-| 10
)
vs the ordinary Swift code:
self.view.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
self.view.addConstraints([
NSLayoutConstraint(item: view, attribute: .Top, relatedBy: .Equal, toItem: self.view, attribute: .Top, multiplier: 1, constant: 10),
NSLayoutConstraint(item: view, attribute: .Right, relatedBy: .Equal, toItem: self.view, attribute: .Right, multiplier: 1, constant: -10),
NSLayoutConstraint(item: view, attribute: .Left, relatedBy: .Equal, toItem: self.view, attribute: .Left, multiplier: 1, constant: 10),
NSLayoutConstraint(item: view, attribute: .Bottom, relatedBy: .Equal, toItem: self.view, attribute: .Bottom, multiplier: 1, constant: -10),
])
You can find MisterFusion on Github here.
A nice library for quickly creating UI layouts.
Original article: Open Source Auto-Layout Library With A Simple And Concise Syntax
©2015 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.