Latest | 1.5.5 |
---|---|
Homepage | https://github.com/bibinjacobpulickal/AutoLayoutProxy |
License | MIT |
Platforms | ios 9.0 |
Authors |
AutoLayoutProxy is a convenient way for creating and constraining views. Avoid repetation of code wherever possible.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate AutoLayoutProxy into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AutoLayoutProxy'
end
Then, run the following command:
$ pod install
Features
- [x] Remove repetitive code while creating new view.
- [x] Fill super view or any other view with/without padding.
- [x] Align center with super view or any other view.
Requirements
- iOS 9.0+
- Xcode 8.3+
- Swift 3.0+
Without AutoLayoutProxy:
import UIKit
class ViewController: UIViewController {
let redView: UIView = {
let view = UIView()
view.backgroundColor = .red
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(redView)
redView.translatesAutoresizingMaskIntoConstraints = false
redView.topAnchor.constraint(greaterThanOrEqualTo: view.safeAreaLayoutGuide.topAnchor, constant: 16).isActive = true
redView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
redView.widthAnchor.constraint(lessThanOrEqualToConstant: view.frame.width - 32).isActive = true
redView.heightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.heightAnchor, multiplier: 0.5, constant: -32).isActive = true
}
}
With AutoLayoutProxy:
import AutoLayoutProxy
class ViewController: UIViewController {
let redView: UIView = create {
$0.backgroundColor = .red
}
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(closureView, layout: {
$0.top >= view.safeAreaLayoutGuide.topAnchor + 16
$0.centerX == view.centerXAnchor
$0.width <= view.frame.width - 32
$0.height == view.safeAreaLayoutGuide.heightAnchor / 2 - 32
})
}
}
License
AutoLayoutProxy is released under the MIT license.
See LICENSE for details.
Latest podspec
{ "name": "AutoLayoutProxy", "version": "1.5.5", "summary": "AutoLayoutProxy allows you to create and layout views with ease.", "description": "AutoLayoutProxy is written in Swift 4.2. Supports from iOS 9.0. This replaces view declaration code and reduces it. Also, reduces auto layout anchoring code.", "homepage": "https://github.com/bibinjacobpulickal/AutoLayoutProxy", "license": "MIT", "authors": { "Bibin Jacob Pulickal": "[email protected]" }, "social_media_url": "https://twitter.com/bibinjacob123", "platforms": { "ios": "9.0" }, "source": { "git": "https://github.com/bibinjacobpulickal/AutoLayoutProxy.git", "tag": "1.5.5" }, "source_files": "AutoLayoutProxy", "swift_version": "4.2" }
Sun, 27 Jan 2019 11:17:09 +0000