Minimal AutoLayout convenience layer. Program constraints succinctly.
Swift Ruby
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Sources
.swift-version
CHANGELOG.md
LICENSE.txt
MiniLayout.podspec
README.md

README.md

MiniLayout

Minimal AutoLayout convenience layer. Program constraints succinctly.

Swift Version Build Status License 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) )

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation

Using CocoaPods:

pod 'MiniLayout'

For legacy Swift 2.3:

pod 'MiniLayout', '~> 1.0.1'

Manually:

Add MiniLayout.swift to your project.

Meta

@yonatsharon

https://github.com/yonat/MiniLayout