Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaakati/k-autolayout
An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.
https://github.com/kaakati/k-autolayout
autolayout autolayout-constraints ios purelayout swift swift-3 swift-language swift3
Last synced: about 1 month ago
JSON representation
An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.
- Host: GitHub
- URL: https://github.com/kaakati/k-autolayout
- Owner: Kaakati
- Created: 2017-08-14T12:10:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-14T12:35:17.000Z (over 7 years ago)
- Last Synced: 2025-01-20T09:09:05.571Z (about 1 month ago)
- Topics: autolayout, autolayout-constraints, ios, purelayout, swift, swift-3, swift-language, swift3
- Language: Swift
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## K-AutoLayout
#### An Autolayout Extension for iOS written in Swift 3An AutoLayout Extension for iOS written in Swift 3 that is very easy to use.
#### HOW TO USE:
Just copy the `AutoLayout.swift` file to your project.### Example
Add yourView as Subview
```swift
var yourView : UILabel = {
let label = UILabel()
label.text = "Your UILabel Text"
label.textAlignment = .center
label.translatesAutoresizingMaskIntoConstraints = false // Don't Forget to add this line.
return label
}()view.addSubview(yourView)
```#### Assign AutoLayout as follow `anchorToTop` if you don't want to set margins:
```swift
yourView.anchorToTop(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor)
```##### OR
#### Assign AutoLayout as follow `anchorWithConstantsToTop` if you want to set margins:
```swift
yourView.anchorWithConstantsToTop(top: view.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0)
```If you want your view to connect to superview bottom edge set `bottom: view.bottomAnchor`
##### OR
To add a `secondView` below `yourView` set it's top: as `yourView.bottomAnchor`
```swift
secondView.anchorWithConstantsToTop(top: yourView.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0)
```