Accio
[](https://travis-ci.org/Akaash Dev/Accio)
Accio is a Collection of Layout Util methods to help developers build Programmatic UI very fast and easy. It completely follows AutoLayout under the hood. It uses declarative approach to do stuff. The main goal of Accio is to remove huge chunks of redundant constraints methods and have a more readable and simple code.
Usage
The general code to anchor a subview to fill its superview be like,
var redView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .red
return view
}()
view.addSubview(redView)
redView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
redView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
redView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
redView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
The same code to do with Accio be like,
var redView: UIView = create {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.backgroundColor = .red
}
view.addSubview(redView)
redView.fill()
Yea, adding layout guides is even simpler,
redView.fill(following: .safeArea)
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Installation
Accio is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Accio'
Author
Akaash Dev, [email protected]
License
Accio is available under the MIT license. See the LICENSE file for more info.