A lightweight Swift library providing convenient Auto Layout helper methods for UIKit.
- Easy-to-use methods for common layout tasks
- Handles
translatesAutoresizingMaskIntoConstraints
automatically - Returns constraint references for further adjustments if needed
You can add AutoLayout
to your project using Swift Package Manager. In Xcode:
- Go to File > Add Packages...
- Enter the repository URL:
https://github.com/componentskit/AutoLayout
- Choose the package and select Add Package
import AutoLayout
let containerView = UIView()
let subView = UIView()
containerView.addSubview(subView)
subView.allEdges(16) // Adds 16 padding on all sides
subView.centerHorizontally()
subView.centerVertically()
subView.width(100)
subView.height(50)
let firstView = UIView()
let secondView = UIView()
containerView.addSubview(firstView)
containerView.addSubview(secondView)
secondView.after(firstView, padding: 8)
subView.horizontally(20)
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.