TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | BSD |
ReleasedLast Release | Jun 2016 |
SPMSupports SPM | ✗ |
Maintained by Daniel Dahan, Daniel Dahan.
Grid is an elegant approach to layouts. It simplifies AutoLayout, as well as, offers a unique row and column based layout system.
Embedded frameworks require a minimum deployment target of iOS 8.
Visit the Installation page to learn how to install Grid using CocoaPods and Carthage.
Grid is a growing project and will encounter changes throughout its development. It is recommended that the Changelog be reviewed prior to updating versions.
Layout is a UIView extension that simplifies AutoLayout.
Constructing a layout may be done in three ways, using the static library, view instance methods, and a chaining context.
To construct a layout using the static library, a parent view and child view are passed to the Grid method.
let parentView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 500))
let childView = UIView()
Layout.topLeft(parentView, child: childView, top: 50, left: 50)
To construct a layout using the view instance methods, a parentView passes in a childView to its grid method and then supplies the constraint values.
let parentView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 500))
let childView = UIView()
parentView.layout.topLeft(childView, top: 50, left: 50)
To construct a layout using a chaining context, a parentView passes in a childView to its grid context method and then supplies the constraint values.
let parentView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 500))
let childView = UIView()
parentView.layout(childView).top(50).left(50)
Canvas is a UIView extension that provides a row and column based layout system.
Canvas uses rows and columns to layout views. The entire layout is calculated mathematically.
let btn1: UIButton = UIButton()
btn1.backgroundColor = .redColor()
btn1.setTitle("Button 1", forState: .Normal)
let btn2: UIButton = UIButton()
btn2.backgroundColor = .greenColor()
btn2.setTitle("Button 2", forState: .Normal)
let btn3: UIButton = UIButton()
btn3.backgroundColor = .blueColor()
btn3.setTitle("Button 3", forState: .Normal)
btn1.canvas.columns = 2
btn2.canvas.columns = 2
btn3.canvas.columns = 2
view.canvas.axis.columns = 6
view.canvas.interimSpace = 16
view.canvas.contentInsets = Insets(top: 100, left: 16, bottom: 100, right: 16)
view.canvas.views = [btn1, btn2, btn3]
Copyright © 2015 - 2016, Daniel Dahan and CosmicMind, Inc. http://cosmicmind.io. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Grid nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.