Latest 1.4.1
Homepage https://github.com/yonat/MiniLayout
License MIT
Platforms ios 9.0, requires ARC
Authors

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) )

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

Latest podspec

{
    "name": "MiniLayout",
    "version": "1.4.1",
    "summary": "Minimal AutoLayout convenience layer. Program constraints succinctly.",
    "description": "Usage:nn```swiftnview.addConstrainedSubview(label, constrain: .leading, .top)nview.constrain(textField, at: .leading, to: label, at: .trailing, diff: 8)n```",
    "homepage": "https://github.com/yonat/MiniLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Yonat Sharon": "[email protected]"
    },
    "social_media_url": "http://twitter.com/yonatsharon",
    "swift_version": "4.2",
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/yonat/MiniLayout.git",
        "tag": "1.4.1"
    },
    "source_files": "Sources/MiniLayout.swift"
}

Pin It on Pinterest

Share This