Latest 1.2.0
Homepage https://github.com/berbschloe/squidward
License MIT
Platforms ios 10.0

A collection of additional layout anchor types meant to complement UIKit’s existing constraint system.

Swift
CocoaPods

Requirements

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0+

Instalation

CocoaPods

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

pod 'Squidward', '1.2.0'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

dependencies: [
    .package(url: "https://github.com/berbschloe/Squidward.git", from: "1.2.0")
]

Usage

Importing

It would be recommended to add the library globally because it can get annoying importing it everywhere.

// Add this to a GlobalImports.swift
@_exported import Squidward

Constraints

Old Way


let childView = UIView()

override func viewDidLoad() {
    super.viewDidLoad()

    NSLayoutConstraint.activate([
        childView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 10),
        childView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 10),
        childView.topAnchor.constraint(equalTo: view.topAnchor, constant: -10),
        childView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -10),
    ])
}

Squidward Way

let childView = UIView()

override func viewDidLoad() {
    super.viewDidLoad()

    NSLayoutConstraint.activate([
        childView.edgeAnchors.constraint(equalTo: view.edgeAnchors, constant: 10)
    ])
}

Variants


childView.edgeAnchors.constraint(equalTo: view.edgeAnchors) // default zero constant

childView.edgeAnchors.constraint(edges: [.left, .right, .top], equalTo: view.edgeAnchors) // constrain specific edges

childView.edgeAnchors.constraint(
    equalTo: view.edgeAnchors, 
    constant: UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40) // custom insets with no need to apply a negative
)

Latest podspec

{
    "name": "Squidward",
    "version": "1.2.0",
    "summary": "A collection of additional layout anchor types meant to complement UIKit's existing constraint system.",
    "homepage": "https://github.com/berbschloe/squidward",
    "license": "MIT",
    "authors": "Brandon Erbschloe",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/berbschloe/squidward.git",
        "tag": "1.2.0"
    },
    "source_files": "Squidward/**/*.{h,m,swift}",
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This