https://github.com/shaps80/swiftlayout
A Swift library for programmatically dealing with AutoLayout
https://github.com/shaps80/swiftlayout
autolayout ios layout macos osx swift
Last synced: about 1 month ago
JSON representation
A Swift library for programmatically dealing with AutoLayout
- Host: GitHub
- URL: https://github.com/shaps80/swiftlayout
- Owner: shaps80
- License: mit
- Created: 2016-01-23T00:15:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-05T10:15:09.000Z (almost 9 years ago)
- Last Synced: 2025-02-12T09:23:21.038Z (over 1 year ago)
- Topics: autolayout, ios, layout, macos, osx, swift
- Language: Swift
- Size: 157 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# SwiftLayout
[](http://cocoapods.org/pods/SwiftLayout)
[](http://cocoapods.org/pods/SwiftLayout)
[](http://cocoapods.org/pods/SwiftLayout)
#### 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__
```swift
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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod "SwiftLayout"
```
## Author
Shaps Mohsenin, shapsuk@me.com
## 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