Grid 1.0.4

Grid 1.0.4

TestsTested
LangLanguage SwiftSwift
License BSD
ReleasedLast Release Jun 2016
SPMSupports SPM

Maintained by Daniel Dahan, Daniel Dahan.



Grid 1.0.4

image

Welcome to Grid

Grid is an elegant approach to layouts. It simplifies AutoLayout, as well as, offers a unique row and column based layout system.

Features

  • [x] Static Library
  • [x] View Instance Methods
  • [x] Chaining Context
  • [x] Layouts Using Rows & Columns

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Communication

  • If you need help, use Stack Overflow. (Tag ‘cosmicmind’)
  • If you’d like to ask a general question, use Stack Overflow.
  • If you found a bug, and can provide steps to reliably reproduce it, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Embedded frameworks require a minimum deployment target of iOS 8.

Visit the Installation page to learn how to install Grid using CocoaPods and Carthage.

Changelog

Grid is a growing project and will encounter changes throughout its development. It is recommended that the Changelog be reviewed prior to updating versions.

Examples

  • Visit the Examples directory to see example projects using Grid.
  • The Installation page has documentation on how to run the example projects.

Layout

Layout is a UIView extension that simplifies AutoLayout.

image

Initialization

Constructing a layout may be done in three ways, using the static library, view instance methods, and a chaining context.

Static Library

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)
View Instance Methods

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)
Chaining Context

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)

Learn More About Layout

Canvas

Canvas is a UIView extension that provides a row and column based layout system.

image

Rows & Columns

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]

Learn More About Canvas

License

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.