Last active
September 6, 2016 15:21
-
-
Save giginet/cccfcceb2aff7b8d662e6f04cd956d0f to your computer and use it in GitHub Desktop.
PureLayoutExtension
This file contains 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
import UIKit | |
import PureLayout | |
extension CollectionType where Generator.Element == NSLayoutConstraint { | |
func autoInstallConstraints() { | |
(self as! NSArray).autoInstallConstraints() | |
} | |
func autoRemoveConstraints() { | |
(self as! NSArray).autoRemoveConstraints() | |
} | |
func autoIdentifyConstraints(identifier: String) { | |
(self as! NSArray).autoIdentifyConstraints(identifier) | |
} | |
} | |
extension CollectionType where Generator.Element == UIView { | |
func autoAlignViews(to edge: ALEdge) { | |
(self as! NSArray).autoAlignViewsToEdge(edge) | |
} | |
func autoAlignViews(to axis: ALAxis) { | |
(self as! NSArray).autoAlignViewsToAxis(axis) | |
} | |
func autoMatchViews(dimension dimension: ALDimension) { | |
(self as! NSArray).autoMatchViewsDimension(dimension) | |
} | |
func autoSetViews(dimention dimention: ALDimension, to size: CGFloat) { | |
(self as! NSArray).autoSetViewsDimension(.Height, toSize:size) | |
} | |
func autoSetViewsDimensions(to size: CGSize) { | |
(self as! NSArray).autoSetViewsDimensionsToSize(size) | |
} | |
func autoDistributeViewsAlong(axis axis: ALAxis, alignedTo: ALAttribute, withFixedSpacing fixedSpacing: CGFloat, insetSpacing: Bool = true, matchedSizes: Bool = true) { | |
(self as! NSArray).autoDistributeViewsAlongAxis(axis, | |
alignedTo: alignedTo, | |
withFixedSpacing: fixedSpacing, | |
insetSpacing: insetSpacing, | |
matchedSizes: matchedSizes) | |
} | |
func autoDistributeViewsAlong(axis: ALAxis, alignedTo: ALAttribute, withFixedSize fixedSize: CGFloat, insetSpacing: Bool = true) { | |
(self as! NSArray).autoDistributeViewsAlongAxis(axis, | |
alignedTo: alignedTo, | |
withFixedSize: fixedSize, | |
insetSpacing: insetSpacing) | |
} | |
func autoRemoveAllConstraints() { | |
self.forEach { $0.autoRemoveAllConstrains() } | |
} | |
} | |
extension UIView { | |
func autoRemoveAllConstrains() { | |
self.constraints.autoRemoveConstraints() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment