Lightweight Swift framework for Apple's Auto-Layout

Overview

EasySwiftLayout

Platform Cocoapods Compatible Carthage compatible

I am glad to share with you a lightweight Swift framework for Apple's Auto-Layout. It helps you write readable and compact UI code using simple API.

At first, it was only a few extenstions of UIView desiged for some of my commercial projects, but eventually code continued to grow, so I decided to move it to a seperate framework. I hope some of you find it helpful, so feel free to share your feedback and give some stars to EasySwiftLayout!

If you want to report bug or request new feature - open a ticket. I will try my best to cover them as soon as posible.

Contents

Requirements

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4+

Documentation

All methods in EasySwiftLayout designed to be self-explaining, but at the same time all of them includes detail description of usage. You can check it both in code by pressing key and clicking on the method, and in our API Cheat Sheet section down below.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate EasySwiftLayout into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'EasySwiftLayout'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate EasySwiftLayout into your Xcode project using Carthage, specify it in your Cartfile:

github "denandreychuk/EasySwiftLayout"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but EasySwiftLayout does support its use on supported platforms.

Once you have your Swift package set up, adding EasySwiftLayout as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/Pimine/EasySwiftLayout.git", .upToNextMajor(from: "1.6.0"))
]

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate EasySwiftLayout into your project manually.

Embedded Framework

  • Clone this repo by running:

    $ git clone https://github.com/denandreychuk/EasySwiftLayout.git
  • Navigate to the project folder and open EasySwiftLayout.xcodeproj.

  • Select scheme Build Framework by pressing ^ + 0 and run it on any device. It will automatically generate for you EasySwiftLayout.framework file and open it in Finder.

  • Move this file to your project folder.

  • Select your application in the Project Navigator (blue icon) to navigate to the target configuration window.

  • Select the desired target under the "Targets" heading in the sidebar.

  • In "General" tab click on the + button under the "Embedded Binaries" section (in Xcode 11 it calls Frameworks, Libraries, and Embedded Content) and select moved EasySwiftLayout.framework file.

  • Done.

    The EasySwiftLayout.framework is automatically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.

Usage

Quick Start

import EasySwiftLayout

class ViewController: UIViewController {
    private let boxView = UIView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addAndLayoutSubviews()
    }
    
    private func addAndLayoutSubviews() {        
        boxView
            .add(toSuperview: view)
            .centerInSuperview()
            .size(toSquareWithSide: 50)
    }
}

Example

EasySwiftLayout comes with project example. You can check out how easily you can create screens like this with ESL:

  • Navigate to the project folder and open EasySwiftLayout.xcodeproj.
  • Select scheme Example-IOS by pressing ^ + 0 and just run it on any device.

API Cheat Sheet

UIView Extenstions:

Helpers

add(toSuperview:)
Summary

Adds the view as a subview of specified superview.

Declaration
func add(toSuperview superview: UIView) -> Self
Parameters
Parameter Type Description
superview UIView The superview to which add subview.
Returns

self with attribute @discardableResult.

Declared In

UIView + Helpers.swift

Size Methods (Constants)

width(_:usingRelation:priority:)
Summary

Sets the width of the view using the specified type of relation to the given size with the priority of the constraint.

Declaration
func width(_ width: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints the width anchor using NSLayoutConstraint.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Pass size greater than zero, otherwise this method will have no effect.

Parameters
Parameter Type Description
width CGFloat The value to set this view width to.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

height(_:usingRelation:priority:)
Summary

Sets the height of the view using the specified type of relation to the given size with the priority of the constraint.

Declaration
func height(_ height: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints the height anchor using NSLayoutConstraint.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Pass size greater than zero, otherwise this method will have no effect.

Parameters
Parameter Type Description
height CGFloat The value to set this view height to.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

size(_:usingRelation:priority:)
Summary

Sets the dimensions of the view using the specified type of relation to the given size with the priority of the constraint.

Declaration
func size(_ size: CGSize, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints the height and width anchors using NSLayoutConstraint

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Pass size greater than zero, otherwise this method will have no effect.

Parameters
Parameter Type Description
size CGSize The size to set this view dimensions to.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

size(toSquareWithSide:usingRelation:priority:)
Summary

Sets the dimensions of the view to a square with the side using the specified type of relation to the given size with the priority of the constraint.

Declaration
func size(toSquareWithSide side: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints width and height anchors using NSLayoutConstraint to match square size.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Pass side greater than zero, otherwise this method will have no effect.

Parameters
Parameter Type Description
side CGFloat Square side to set this view dimensions to.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

Size Methods (Another view)

width(match:withInset:usingRelation:priority:)
Summary

Sets the width of the view using the specified type of relation to the width of another view with the inset and priority of the constraint.

Declaration
func width(match anotherView: UIView, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints width and height anchors using NSLayoutConstraint to match square size.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Parameters
Parameter Type Description
anotherView UIView Another view to set this view width to.
inset CGFloat The value to inset (or shrunk) the width. Negative value cause the width to be outset (or expanded).
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

height(match:withInset:usingRelation:priority:)
Summary

Sets the height of the view using the specified type of relation to the height of another view with the inset and priority of the constraint.

Declaration
func height(match anotherView: UIView, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints width and height anchors using NSLayoutConstraint to match square size.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Parameters
Parameter Type Description
anotherView UIView Another view to set this view height to.
inset CGFloat The value to inset (or shrunk) the height. Negative value cause the height to be outset (or expanded).
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

size(match:withInsets:usingRelation:priority:)
Summary

Sets the size of the view using the specified type of relation to the size of another view with the insets and priority of the constraints.

Declaration
func size(match anotherView: UIView, withInsets insets: ESLSizeInsets = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints width and height anchors using NSLayoutConstraint to match square size.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Parameters
Parameter Type Description
anotherView UIView Another view to set this view height to.
insets ESLSizeInsets The values to inset (or shrunk) the size. Negative values cause the size to be outset (or expanded).
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

size(match:withInset:usingRelation:priority:)
Summary

Sets the size of the view using the specified type of relation to the size of another view with the insets and priority of the constraints.

Declaration
func size(match anotherView: UIView, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Constraints width and height anchors using NSLayoutConstraint to match square size.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Parameters
Parameter Type Description
anotherView UIView Another view to set this view height to.
inset CGFloat The value to inset (or shrunk) the size. Negative value cause the size to be outset (or expanded).
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Size.swift

Pin Methods

pin(topTo:leftTo:bottomTo:rightTo:withInsets:priority:)
Summary

Pins the edges to the given NSLayoutAxisAnchors with the insets and priority of the constraints.

Declaration
func pin(topTo top: NSLayoutYAxisAnchor? = nil, leftTo left: NSLayoutXAxisAnchor? = nil, bottomTo bottom: NSLayoutYAxisAnchor? = nil, rightTo right: NSLayoutXAxisAnchor? = nil, withInsets insets: UIEdgeInsets = .zero, priority: UILayoutPriority = .required) -> Self
Discussion
  • Compact version of default Swift layout. Allows you to pin edges to specific NSLayoutAxisAnchor.

  • To make Auto-Layout works properly, it automatically sets view’s property translatesAutoresizingMaskIntoConstraints to false

Precondition

You should pass at least one anchor, otherwise this method will have no effect.

Parameters
Parameter Type Description
top NSLayoutYAxisAnchor The anchor to pin top to.
left NSLayoutXAxisAnchor The anchor to pin left to.
bottom NSLayoutYAxisAnchor The anchor to pin bottom to.
right NSLayoutXAxisAnchor The anchor to pin right to.
insets UIEdgeInsets The insets between the edges.
priority UILayoutPriority The priority of the constraints.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdge(_:toEdge:ofView:withInset:usingRelation:priority:)
Summary

Pins the edge of the view using the specified type of relation to the given edge of another view with the inset and priority of the constraint.

Declaration
func pinEdge(_ edge: ESLEdge, toEdge pinningEdge: ESLEdge, ofView anotherView: UIView, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Consider, accordingly to Apple's documentation, you cannot pin edges with different axis, otherwise it will throw fatal error.

  • To make Auto-Layout works properly, it automatically sets view’s property translatesAutoresizingMaskIntoConstraints to false.

Precondition
  • Another view must be in the same view hierarchy as this view.

  • Pin edges with same axis or method will throw fatal error.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
pinningEdge ESLEdge The edge of another view to pin to.
anotherView NSLayoutYAxisAnchor Another view to pin to.
inset CGFloat The inset between the edge of this view and the edge of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdge(_:toSameEdgeOfView:withInset:usingRelation:priority:)
Summary

Pins the given edge of the view using the specified type of relation to the corresponding margin of another view with the inset and priority of the constraint.

Declaration
func pinEdge(_ edge: ESLEdge, toSameEdgeOfView anotherView: UIView, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view’s property translatesAutoresizingMaskIntoConstraints to false.

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
anotherView NSLayoutYAxisAnchor Another view to pin to.
inset CGFloat The inset beetween the edge of this view and the corresponding edge of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(_:toSameEdgesOfView:withInsets:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of another view with the insets and priority of the constraints.

Declaration
func pinEdges(_ edges: [ESLEdge] = ESLEdge.all, toSameEdgesOfView anotherView: UIView, withInsets insets: UIEdgeInsets = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you need to customize the insets based on the edge, use pinEdges(_:toSameEdgesOfView:withInset:usingRelation:priority:).

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
anotherView NSLayoutYAxisAnchor Another view to pin to.
insets UIEdgeInsets The insets beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(_:toSameEdgesOfView:withInset:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of another view with the equal insets and priority of the constraints.

Declaration
func pinEdges(_ edges: [ESLEdge] = ESLEdge.all, toSameEdgesOfView anotherView: UIView, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you don’t need to customize the insets based on the edge, use pinEdges(_:toSameEdgesOfView:withInsets:usingRelation:priority:).

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
anotherView NSLayoutYAxisAnchor Another view to pin to.
insets CGFloat The inset beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(ofGroup:toSameEdgesOfView:withInset:usingRelation:priority:)
Summary

Pins edges of the view of the given group using the specified type of relation to the corresponding margins of another view with the equal insets and priority of the constraints.

Declaration
func pinEdges(ofGroup edgeGroup: ESLEdgeGroup, toSameEdgesOfView anotherView: UIView, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
edgeGroup ESLEdgeGroup The group of edges of this view to pin to.
anotherView NSLayoutYAxisAnchor Another view to pin to.
insets CGFloat The inset beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(toSameEdgesOfView:excludingEdge:withInsets:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of another view with the insets and priority of the constraints, excluding one edge

Declaration
func pinEdges(toSameEdgesOfView anotherView: UIView, excludingEdge excludedEdge: ESLEdge, withInsets insets: UIEdgeInsets = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you don’t need to customize the insets based on the edge, use pinEdges(toSameEdgesOfView:excludingEdge:withInset:usingRelation:priority:).
  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.
Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
anotherView NSLayoutYAxisAnchor Another view to pin to.
excludedEdge ESLEdge The edge to be ingored and not pinned.
insets UIEdgeInsets The insets beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(toSameEdgesOfView:excludingEdge:withInset:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of another view with the equal inset and priority of the constraints, excluding one edge.

Declaration
func pinEdges(toSameEdgesOfView anotherView: UIView, excludingEdge excludedEdge: ESLEdge, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you need to customize the insets based on the edge, use pinEdges(toSameEdgesOfView:excludingEdge:withInsets:usingRelation:priority:).
  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.
Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
anotherView NSLayoutYAxisAnchor Another view to pin to.
excludedEdge ESLEdge The edge to be ingored and not pinned.
inset CGFloat The inset beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdge(_:toEdge:ofGuide:withInset:usingRelation:priority:)
Summary

Pins the edge of the view using the specified type of relation to the given edge of guide with the inset and priority of the constraint.

Declaration
func pinEdge(_ edge: ESLEdge, toEdge pinningEdge: ESLEdge, ofGuide guide: ESLGuide, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Consider, accordingly to Apple's documentation, you cannot pin edges with different axis, otherwise it will throw fatal error.

  • To make Auto-Layout works properly, it automatically sets view’s property translatesAutoresizingMaskIntoConstraints to false.

Precondition

Pin edges with same axis or method will throw fatal error.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
pinningEdge ESLEdge The edge of another view to pin to.
guide ESLGuide The guide to pin to..
inset CGFloat The inset between the edge of this view and the edge of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdge(_:toSameEdgeOfGuide:withInset:usingRelation:priority:)
Summary

Pins the given edge of the view using the specified type of relation to the corresponding margin of guide with the inset and priority of the constraint.

Declaration
func pinEdge(_ edge: ESLEdge, toSameEdgeOfGuide guide: ESLGuide, withInset inset: CGFloat = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view’s property translatesAutoresizingMaskIntoConstraints to false.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
guide ESLGuide The guide to pin to.
inset CGFloat The inset beetween the edge of this view and the corresponding edge of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(_:toSameEdgesOfGuide:withInsets:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of guide with the insets and priority of the constraints.

Declaration
func pinEdges(_ edges: [ESLEdge] = ESLEdge.all, toSameEdgesOfGuide guide: ESLGuide, withInsets insets: UIEdgeInsets = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you need to customize the insets based on the edge, use pinEdges(_:toSameEdgesOfGuide:withInset:usingRelation:priority:).

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
guide ESLGuide The guide to pin to..
insets UIEdgeInsets The insets beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(_:toSameEdgesOfGuide:withInset:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of guide with the equal insets and priority of the constraints.

Declaration
func pinEdges(_ edges: [ESLEdge] = ESLEdge.all, toSameEdgesOfGuide guide: ESLGuide, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you don’t need to customize the insets based on the edge, use pinEdges(_:toSameEdgesOfGuide:withInsets:usingRelation:priority:).

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
guide ESLGuide The guide to pin to.
insets CGFloat The inset beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(ofGroup:toSameEdgesOfGuide:withInset:usingRelation:priority:)
Summary

Pins edges of the view of the given group using the specified type of relation to the corresponding margins of guide with the equal insets and priority of the constraints.

Declaration
func pinEdges(ofGroup edgeGroup: ESLEdgeGroup, toSameEdgesOfGuide guide: ESLGuide, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Parameters
Parameter Type Description
edgeGroup ESLEdgeGroup The group of edges of this view to pin to.
guide ESLGuide The guide to pin to.
insets CGFloat The inset beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(toSameEdgesOfGuide:excludingEdge:withInsets:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of guide with the insets and priority of the constraints, excluding one edge.

Declaration
func pinEdges(toSameEdgesOfGuide guide: ESLGuide, excludingEdge excludedEdge: ESLEdge, withInsets insets: UIEdgeInsets = .zero, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you don’t need to customize the insets based on the edge, use pinEdges(toSameEdgesOfGuide:excludingEdge:withInset:usingRelation:priority:).
  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.
Parameters
Parameter Type Description
guide ESLGuide The guide to pin to.
excludedEdge ESLEdge The edge to be ingored and not pinned.
insets UIEdgeInsets The insets beetween the edges of this view and corresponding edges of another view.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

pinEdges(toSameEdgesOfGuide:excludingEdge:withInset:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of guide with the equal inset and priority of the constraints, excluding one edge.

Declaration
func pinEdges(toSameEdgesOfGuide guide: ESLGuide, excludingEdge excludedEdge: ESLEdge, withInset inset: CGFloat, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • If you need to customize the inset based on the edge, use pinEdges(toSameEdgesOfGuide:excludingEdge:withInsets:usingRelation:priority:).
  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.
Parameters
Parameter Type Description
guide ESLGuide The guide to pin to.
excludedEdge ESLEdge The edge to be ingored and not pinned.
inset CGFloat The inset beetween the edges of this view and corresponding edges of guide.
relation NSLayoutConstraint.Relation The type of relationship for the constraints.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin.swift

Pin to Superview Methods

Just to remind, let's say you have a view called MyView, which has a UIButton(loginButton) over it. In this case, MyView is a superview for loginButton and loginButton is a subview of MyView.

pinEdge(_:toSuperviewEdge:withInset:respectingGuide:usingRelation:priority:)
Summary

Pins the edge of the view using the specified type of relation to the given edge of its superview with the inset and priority of the constraint. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdge(_ edge: ESLEdge, toSuperviewEdge superviewEdge: ESLEdge, withInset inset: CGFloat = .zero, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  • Consider, accordingly to Apple's documentation, you cannot pin edges with different axis, otherwise it will throw fatal error.

  • Use this method only if you want to pin the edge of the view to the opposite margin of its superview, in other cases pinEdgeToSuperview(_:withInset:usingRelation:priority:) would be a better approach.

  • To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition
  • The view should have the superview, otherwise method will have no effect.

  • Pin edges with same axis or method will throw fatal error.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
superviewEdge ESLEdge The edge of its superview to pin to.
inset CGFloat The inset between the edge of this view and the edge of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgeToSuperview(_:withInset:respectingGuide:usingRelation:priority:)
Summary

Pins the given edge of the view using the specified type of relation to the corresponding margin of its superview with the inset and priority of the constraint. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgeToSuperview(_ edge: ESLEdge, withInset inset: CGFloat = .zero, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
edge ESLEdge The edge of this view to pin.
inset CGFloat The inset beetween the edge of this view and the corresponding edge of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgesToSuperview(_:withInsets:respectingGuide:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of its superview with the insets and priority of the constraints. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgesToSuperview(_ edges: [ESLEdge] = ESLEdge.all, withInsets insets: UIEdgeInsets = .zero, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  1. If you don't need to customize the insets based on the edge, use pinEdgesToSuperview(_:withInset:usingRelation:priority:).

  2. To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
insets UIEdgeInsets The insets beetween the edges of this view and the corresponding edges of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgesToSuperview(_:withInset:respectingGuide:usingRelation:priority:)
Summary

Pins the given edges of the view using the specified type of relation to the corresponding margins of its superview with the equal insets and priority of the constraints. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgesToSuperview(_ edges: [ESLEdge] = ESLEdge.all, withInset inset: CGFloat, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  1. If you need to customize the insets based on the edge, use pinEdgesToSuperview(_:withInsets:usingRelation:priority:).

  2. To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
edges [ESLEdge] The edges of this view to pin.
inset CGFloat The inset beetween the edges of this view and the orresponding edges of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgesToSuperview(ofGroup:withInset:respectingGuide:usingRelation:priority:)
Summary

Pins edges of the view of the given group using the specified type of relation to the corresponding margins of its superview with the equal insets and priority of the constraints. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgesToSuperview(ofGroup group: ESLEdgeGroup, withInset inset: CGFloat = .zero, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
group ESLEdgeGroup The group of edges of this view to pin to.
inset CGFloat The inset beetween the edges of this view and the orresponding edges of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgesToSuperview(excludingEdge:withInsets:respectingGuide:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of its superview with the insets and priority of the constraints, excluding one edge. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgesToSuperview(excludingEdge excludedEdge: ESLEdge, withInsets insets: UIEdgeInsets = .zero, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  1. If you don't need to customize the insets based on the edge, use pinEdgesToSuperview(excludingEdge:withInset:usingRelation:priority:).

  2. To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
excludedEdge ESLEdge The edge to be ingored and not pinned.
insets UIEdgeInsets The insets beetween the edges of this view and the orresponding edges of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

pinEdgesToSuperview(excludingEdge:withInset:respectingGuide:usingRelation:priority:)
Summary

Pins the edges of the view using the specified type of relation to the corresponding margins of its superview with the equal inset and priority of the constraints, excluding one edge. Optionally respects one of pre-defined Apple's layout guides.

Declaration
func pinEdgesToSuperview(excludingEdge excludedEdge: ESLEdge, withInset inset: CGFloat, respectingGuide guide: ESLSuperviewGuide = .none, usingRelation relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required) -> Self
Discussion
  1. If you need to customize the insets based on the edge, use pinEdgesToSuperview(excludingEdge:withInset:usingRelation:priority:).

  2. To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false.

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
excludedEdge ESLEdge The edge to be ingored and not pinned.
inset CGFloat The inset beetween the edges of this view and the orresponding edges of its superview.
guide ESLSuperviewGuide The guide to respect in layout.
relation NSLayoutConstraint.Relation The type of relationship for constraint.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Pin(Superview).swift

Center Methods

centerInView(_:withOffset:priority:)
Summary

Centers the view in another view with the offset and priority of the constraint.

Declaration
func centerInView(_ anotherView: UIView, withOffset offset: UIOffset = .zero, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
anotherView UIView Another view to center in.
offset UIOffset Axis offset.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Center.swift

centerInView(_:axis:withOffset:priority:)
Summary

Centers the axis of this view in another view with the offset and priority of the constraint.

Declaration
func centerInView(_ anotherView: UIView, axis: ESLAxis, withOffset offset: CGFloat = .zero, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

Another view must be in the same view hierarchy as this view.

Parameters
Parameter Type Description
anotherView UIView View to center in.
axis ESLAxis Axis to center
offset UIOffset Axis offset.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Center.swift

centerInSuperview(withOffset:priority:)
Summary

Centers the view in its superview view with the offset and priority of the constraint.

Declaration
func centerInSuperview(withOffset offset: UIOffset = .zero, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
offset UIOffset Axis offset.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Center.swift

centerInSuperview(axis:withOffset:priority:)
Summary

Centers the axis of this view in its superview with the offset and priority of the constraint.

Declaration
func centerInSuperview(axis: ESLAxis, withOffset offset: CGFloat = .zero, priority: UILayoutPriority = .required) -> Self
Discussion

To make Auto-Layout works properly, it automatically sets view property translatesAutoresizingMaskIntoConstraints to false

Precondition

The view should have the superview, otherwise this method will have no effect.

Parameters
Parameter Type Description
axis ESLAxis Axis to center.
offset `CGFloat Axis offset.
priority UILayoutPriority The priority of the constraint.
Returns

self with attribute @discardableResult.

Declared In

UIView + Center.swift

License

EasySwiftLayout is released under the MIT license. See LICENSE for details.

You might also like...
Minimal Auto Layout in Swift
Minimal Auto Layout in Swift

Restraint Restraint is a very very small library to help make your use of NSLayoutConstraint in Swift more legible & declarative. Like programmatic vi

Swift microframework for declaring Auto Layout constraints functionally
Swift microframework for declaring Auto Layout constraints functionally

Relayout Relayout is a Swift microframework to make using Auto Layout easier with static and dynamic layouts. Why? If you want to build a UI using App

SuperLayout is a Swift library that makes using Auto Layout a breeze.
SuperLayout is a Swift library that makes using Auto Layout a breeze.

SuperLayout is a library that adds a few custom operators to Swift that makes using the amazing NSLayoutAnchor API for Auto Layout a breeze. SuperLayo

Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.

QuickLayout QuickLayout offers an additional way, to easily manage the Auto Layout using only code. You can harness the power of QuickLayout to align

Declarative Auto Layout in Swift, clean and simple

Tails Tails is a take on declarative Auto Layout. If you don't like typing (like me), it might be your kind of thing! Tails is written in Swift and cu

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Auto Layout made easy
Auto Layout made easy

EasyPeasy is a Swift framework that lets you create Auto Layout constraints programmatically without headaches and never ending boilerplate code. Besi

TinyConstraints is the syntactic sugar that makes Auto Layout sweeter for human use.
TinyConstraints is the syntactic sugar that makes Auto Layout sweeter for human use.

TinyConstraints is the syntactic sugar that makes Auto Layout sweeter for human use. Features Pure Swift 5 sweetness. Everything you can do with Auto

Intuitive and powerful Auto Layout library
Intuitive and powerful Auto Layout library

Align introduces a better alternative to Auto Layout anchors. Semantic. Align APIs focus on your goals, not the math behind Auto Layout constraints. P

Comments
  • Why not return Self in most methods?

    Why not return Self in most methods?

    Hi there. Thanks for the great library, I'm happy to use it in almost all of my Swift projects. But I discovered that in recent releases most methods don't return Self anymore. Why? It was very convenient for chaining method calls.

    opened by mkll 4
Releases(1.6.3)
  • 1.6.3(Oct 6, 2022)

  • 1.6.2(Nov 15, 2021)

  • 1.6.0(Feb 16, 2021)

    Added:

    • Support for Swift Package Manager.
    • Tests for size and center extensions.
    • assertionFailure when expected superview but found nil when attempting to make constraint.

    Updated:

    • Enum ESLAxis cases x, y deprecated and replaced with horizontal and vertical.

    Removed:

    • ESLOffset. Replaced with UIOffset from UIKit.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(May 17, 2020)

    Added:

    • Example project.
    • Small helper method add(toSuperview:) for convenient chaining.

    Updated:

    • API documentation.
    • Internal project structure.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(May 14, 2020)

    Added:

    • Ability to chain pin, center methods. For now, all methods returns self with attribute @discardableResult. This will help to remove some boilerplate code in our daily UI routine.

    • ESLSizeInsets (typealias of UIOffset) instead of ESL2DimentionsInsets (typealias of CGSize). It was just a bad naming, plus UIOffset creates better API rather than CGSize.

    • Swift 5 support.

    Updated:

    • API documentation.

    • Size methods which uses another view for layout. Replaced argument labels to to match.

    • centerInSuperview. Now it requires argument label axis.

    Fixed:

    • Center methods ignored constraints priority.

    • height ignored constraint relation.

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(May 3, 2020)

    Added:

    • Support to set size of the view using another UIView.

    Updated:

    • API documentation.

    Deprecated:

    • Size methods with layout relation as a first argument. Relation moved to base size methods as a second argument with default value NSLayoutRelation.equal.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.3(Mar 14, 2020)

  • 1.3.0(Feb 5, 2020)

    Added:

    • Support for Guides. ESL now supports UILayoutGuide with convenience API, as well as, API for predefined Apple's guides such as layoutMarginsGuide, readableContentGuide, safeAreaLayoutGuide.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.2(Nov 14, 2019)

    Added:

    • Shared Schemes for Carthage.

    Fixed:

    • Carthage: Dependency "EasySwiftLayout" has no shared framework schemes for any of the platforms: iOS.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Nov 11, 2019)

  • 1.2.0(Nov 10, 2019)

    Added:

    • Tags in comments for some methods for better navigation and appearance of Quick Help in Xcode.

    Updated:

    • API Documentation.
    • The order of usingRelation, so that it is passed after non-default parameters.
    • The order of excludingEdge, so that it is passed right before parameter withInsets.

    Fixed:

    • Priority setup for pinEdges(ofGroup:toSameEdgesOfView:withInset:usingRelation:priority:).
    Source code(tar.gz)
    Source code(zip)
  • 1.1.4(Nov 6, 2019)

  • 1.1.3(Nov 6, 2019)

  • 1.1.2(Nov 5, 2019)

  • 1.1.1(Nov 5, 2019)

  • 1.1.0(Nov 5, 2019)

    Added:

    • Support for priorities and relations.
    • 3 new size methods to support relations.
    • 4 new excludingEdge pin methods.
    • 2 new pin methods which takes ESLEdgeGroup.
    • Enum ESLEdgeGroup which have 2 group of edges: horizontal and vertical.

    Updated:

    • Reorganized internal structure of framework.
    • Deprecated pinHorizontalEdgesToSuperview and pinVerticalEdgesToSuperview.
    • Renamed insetMultiplier to directionalMultiplier and removed it from the public API.

    Removed:

    • ESLAnchor.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.6(Oct 29, 2019)

    This is a small release, mainly focused on improving documentation and increasing readability of the code.

    • Improved documentation.
    • Changed a few internal variables.
    • Changed name of build scheme (for manual installation of framework)
    Source code(tar.gz)
    Source code(zip)
Owner
null
Lightweight declarative auto-layout framework for Swift

SwiftyLayout SwiftyLayout is a framework that allows to describe layout constraints (ie NSLayoutConstraint) as a simple mathematical formula in a Swif

Hisakuni Fujimoto 15 Nov 7, 2017
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) It’s equivalent to iOS 9 API: view.centerXAnchor.cons

Javier Zhang 74 Oct 19, 2022
Auto Layout made easy with the Custom Layout.

Auto Layout made easy with the Custom Layout. Getting started CocoaPods CocoaPods is a dependency manager for Cocoa projects. You can install it with

Malith Nadeeshan 1 Jan 16, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

layoutBox 2.1k Dec 22, 2022
A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:

Cartography ?? ?? Using Cartography, you can set up your Auto Layout constraints in declarative code and without any stringly typing! In short, it all

Robb Böhnke 7.3k Jan 4, 2023
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.

KVConstraintKit KVConstraintKit is a DSL to make easy & impressive Auto Layout constraints on iOS, tvOS & OSX with Swift Installation Using CocoaPods

Keshav Vishwkarma 90 Sep 1, 2022
A compact but full-featured Auto Layout DSL for Swift

Mortar allows you to create Auto Layout constraints using concise, simple code statements. Use this: view1.m_right |=| view2.m_left - 12.0 Instead of:

Jason Fieldman 83 Jan 29, 2022
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible.

The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. PureLayout extends UIView/NSView, NSArray, and NSLayoutConstrai

PureLayout 7.6k Jan 6, 2023
Auto Layout In Swift Made Easy

Swiftstraints Swiftstraints can turn verbose auto-layout code: let constraint = NSLayoutConstraint(item: blueView, attr

null 119 Jan 29, 2022
Yet Another Swift Auto Layout DSL

FormationLayout Documentation FormationLayout is the top level layout class for one root view. FormationLayout takes a UIView as its rootView. transla

Evan Liu 53 Mar 31, 2022