mirror of https://github.com/SnapKit/SnapKit
Added activate/deactivate
This commit is contained in:
parent
ded4778181
commit
3c3a76cf6e
|
@ -291,6 +291,28 @@ final public class Constraint {
|
||||||
self.uninstallFromView()
|
self.uninstallFromView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func activate() {
|
||||||
|
if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil {
|
||||||
|
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||||
|
if layoutConstraints.count > 0 {
|
||||||
|
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.install()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deactivate() {
|
||||||
|
if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil {
|
||||||
|
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||||
|
if layoutConstraints.count > 0 {
|
||||||
|
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.uninstall()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: internal
|
// MARK: internal
|
||||||
|
|
||||||
internal func installOnView(updateExisting: Bool = false) -> [LayoutConstraint] {
|
internal func installOnView(updateExisting: Bool = false) -> [LayoutConstraint] {
|
||||||
|
|
Loading…
Reference in New Issue