Latest 4.0.0
Homepage https://github.com/shaps80/SwiftLayout
License MIT
Platforms ios 8.0, osx 10.10, requires ARC
Authors

SwiftLayout

Version
License
Platform

Note

By default Swift Layout is now using Swift 3.0. You can install either 3.0 or 2.2 version as follows:

Swift 3.0
pod 'SwiftLayout'

Swift 2.3 – Not Supported

Swift 2.2
pod 'SwiftLayout', '1.3.1'


Often we have to use AutoLayout in our apps. In fact sometimes, we can’t even use Interface Builder. Which means we need to add these programmatically.

I had previously done this manually, even occassionally used a 3rd party lib/pod. There are some great libs out there, but I wanted to build my own. Both for my own understanding and also to provide a cleaner interface that made programmatic AutoLayout easy.

Introducing SwiftLayout

import SwiftLayout

class ViewController: UIViewController {

    override func viewDidLoad() {
      super.viewDidLoad()

      let views = [ addView(), addView(), addView() ]
      views.distribute(along: .vertical, in: view)
      views.size(width: 100, height: 50)
      views.align(axis: .horizontal, in: view)

      let label = UILabel()
      view.addSubview(label)
      label.pin(edge: .Left, to: .Right, of: view, margin: 15)
    }

}

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

SwiftLayout is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftLayout"

Author

Shaps Mohsenin, [email protected]

License

SwiftLayout is available under the MIT license. See the LICENSE file for more info.

Attributes

Icon: Cluster by Thomas Helbig from the Noun Project

Latest podspec

{
    "name": "SwiftLayout",
    "version": "4.0.0",
    "summary": "A Swift library for programmatically dealing with AutoLayout",
    "homepage": "https://github.com/shaps80/SwiftLayout",
    "license": "MIT",
    "authors": {
        "Shaps Mohsenin": "[email protected]"
    },
    "source": {
        "git": "https://github.com/shaps80/SwiftLayout.git",
        "tag": "4.0.0"
    },
    "social_media_url": "https://twitter.com/shaps",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This