Latest 1.0.0
License MIT
Platforms ios 10, requires ARC

Simple API for Auto Layout interfaces. Works with iOS and macOS.

Pins takes care of the mundane and simplifies the code you need to write whenever possible. You don’t need to set translatesAutoresizingMaskIntoConstraints to false all over the place, calling pin will do that for you. You probably want the constraints you just created to be activated so Pins will do that for you too. Needing to negate padding when creating constraints to right, bottom or trailing anchors isn’t intuitive so pins will take care of that. If Pins doesn’t do everything you need or you need to reference the constraints later no problem, they are returned whenever you call pin so you can have full control.



  1. Add the jduff/Pins project to your Cartfile.
    github "jduff/Pins"
  2. Run carthage update, then add the framework into your project.
  3. Import the Pins framework/module.
    • Swift: import Pins


  1. Add the following information to your Podfile.

target ‘‘ do
pod ‘Pins’, ‘~> 1.0’

2. Run `pod install`
3. Import the Pins framework/module.
- Swift: `import Pins`

## Usage

``` swift
// Pin bounds, 4 constraints created and activated mainView.leftAnchor, topTo: mainView.topAnchor, trailingTo: mainView.rightAnchor, bottomTo: mainView.bottomAnchor) mainView) // same as above

// Pins are optional when it makes sense, 2 constraints created and activated mainView.leftAnchor, topTo: nil, trailingTo: mainView.rightAnchor, bottomTo: nil)

// Pin height and width, 2 constraints created and activated 20, width: 10)

// Pin top with padding, 1 constraint with constant of 10 created and activated, to: mainView.topAnchor, padding: 10)
let topConstraint =, to: mainView, padding: 10) // same as above

// Pin to UILayout guides
let space = UILayoutGuide()
mainView.addLayoutGuide(space), to: space.leftAnchor, padding: 10)
  • When you call pin on a View we set translatesAutoresizingMaskIntoConstraints to false so you don’t need to.
  • On the NSLayoutConstraint that is created we also set isActive to true so it’s already activated for you.
  • We return any NSLayoutConstraint objects that are created when you call pin so that you can reference them later or do anything else you might need.
  • For simplicity, the padding value will be appropriately negated when applied to right/trailing/bottom edges. If you wish to push views further to the right, use a negative padding value.


Pins is licensed under the MIT License. See the LICENSE file for more information.

Latest podspec

    "name": "Pins",
    "version": "1.0.0",
    "summary": "Simple API for Auto Layout interfaces.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "John Duff": "[email protected]"
    "platforms": {
        "ios": "10"
    "requires_arc": true,
    "source": {
        "git": "",
        "tag": "v1.0.0",
        "submodules": true
    "source_files": "Pins/**/*.{h,swift}",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This