Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Auto-Layout Library With A Simple And Concise Syntax

  •  
  •  
  •  
  •  
  •  

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:

let view = UIView()
self.view.addLayoutSubview(view, andConstraints:
    view.Top    |+| 10,
    view.Right  |-| 10,
    view.Left   |+| 10,
    view.Bottom |-| 10
)

vs the ordinary Swift code:

let view = UIView()
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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments