Created
November 5, 2017 13:14
-
-
Save douglastaquary/9cda1e792c1383ef94218c71b7ea632f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ConceptLayout.swift | |
| // Concept-Elements-Swift | |
| // | |
| // Created by Douglas Taquary on 05/11/17. | |
| // Copyright © 2017. All rights reserved. | |
| // | |
| import UIKit | |
| public class ConceptLayout { | |
| /** | |
| Returns an array of constraints | |
| */ | |
| public class func constraints(_ visualFormat:String, views:[String:AnyObject]) -> [NSLayoutConstraint] | |
| { | |
| return NSLayoutConstraint.constraints(withVisualFormat: visualFormat, options: [], metrics: nil, views: views) | |
| } | |
| /** | |
| Returns an constraint between two views | |
| */ | |
| public class func constraintTo(_ item:AnyObject, toItem:AnyObject?, align:NSLayoutAttribute, multiplier: CGFloat = 1, constant: CGFloat = 0 ) -> NSLayoutConstraint | |
| { | |
| return NSLayoutConstraint(item: item, attribute: align, relatedBy: .equal, toItem: toItem, attribute: align, multiplier: multiplier, constant: constant) | |
| } | |
| /// - Parameters: | |
| /// - item: UIView for the constraint. | |
| /// - attribute: NSLayoutAttribute enum value which the constraint will be created | |
| /// - Parameter value: CGFloat value for the attribute constant value | |
| /// - Returns: NSLayoutConstraint created | |
| public class func constraintFor(_ item: UIView, attribute: NSLayoutAttribute, value: CGFloat) -> NSLayoutConstraint { | |
| return NSLayoutConstraint(item: item, attribute: attribute, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: value) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment