Popularity
0.7
Stable
Activity
0.0
Stable
8
3
3

Programming language: Swift
License: MIT License
Tags: Layout    
Latest version: v1.4.2

MiniLayout alternatives and similar libraries

Based on the "Layout" category.
Alternatively, view MiniLayout alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of MiniLayout or a related project?

Add another 'Layout' Library

README

MiniLayout

Minimal AutoLayout convenience layer. Program constraints succinctly.

Swift Version Build Status [License][license-url] CocoaPods Compatible
Platform PRs Welcome

Usage

Put label over textField

// using MiniLayout:
view.constrain(label, at: .leading, to: textField)
view.constrain(textField, at: .top, to: label, at: .bottom, diff: 8)

// without MiniLayout:
view.addConstraint( NSLayoutConstraint(item: label, attribute: .leading, relatedBy: .equal, toItem: textField, attribute: .leading, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: textField, attribute: .top, relatedBy: .equal, toItem: label, attribute: .bottom, multiplier: 1, constant: 8) )

Add button at the center of view

// using MiniLayout:
view.addConstrainedSubview(button, constrain: .centerX, .centerY)

// without MiniLayout:
view.addSubview(button)
button.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint( NSLayoutConstraint(item: button, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: button, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 1, constant: 0) )

Add child view controller covering all but the bottom margin

// using MiniLayout:
addConstrainedChild(vc, constrain: .bottomMargin, .top, .left, .right)

// without MiniLayout:
addChild(vc)
view.addSubview(vc.view)
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .bottomMargin, relatedBy: .equal, toItem: view, attribute: .bottomMargin, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1, constant: 0) )
vc.didMove(toParent: self)

Installation

Manually:

Add MiniLayout.swift to your project.

Using CocoaPods:

pod 'MiniLayout'

Legacy versions:

Swift version MiniLayout version
4.0 (Xcode 9.4) pod 'MiniLayout', '~> 1.2.1'
3 pod 'MiniLayout', '~> 1.1.0'
2.3 pod 'MiniLayout', '~> 1.0.1'

Meta

@yonatsharon

https://github.com/yonat/MiniLayout


*Note that all licence references and agreements mentioned in the MiniLayout README section above are relevant to that project's source code only.