Created
April 24, 2019 13:21
-
-
Save onmyway133/46bcbb85034e47f8727e374b8bb3ad4e 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
public extension NSLayoutConstraint { | |
/// Disable auto resizing mask and activate constraints | |
/// | |
/// - Parameter constraints: constraints to activate | |
static func on(_ constraints: [NSLayoutConstraint]) { | |
constraints.forEach { | |
($0.firstItem as? UIView)?.translatesAutoresizingMaskIntoConstraints = false | |
$0.isActive = true | |
} | |
} | |
static func on(_ constraintsArray: [[NSLayoutConstraint]]) { | |
let constraints = constraintsArray.flatMap({ $0 }) | |
NSLayoutConstraint.on(constraints) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment