mirror of https://github.com/SnapKit/SnapKit
Add call to activateConstraints on iOS8+ and fix build issues for OS X.
This commit is contained in:
parent
ee34ec542f
commit
2afe4d47ec
|
@ -315,7 +315,11 @@ internal class ConcreteConstraint: Constraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add constraints
|
// add constraints
|
||||||
installOnView!.addConstraints(newLayoutConstraints)
|
if #available(iOS 8.0, OSX 10.7, *) {
|
||||||
|
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
|
||||||
|
} else {
|
||||||
|
installOnView!.addConstraints(newLayoutConstraints)
|
||||||
|
}
|
||||||
|
|
||||||
// set install info
|
// set install info
|
||||||
self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
|
self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
|
||||||
|
@ -337,9 +341,10 @@ internal class ConcreteConstraint: Constraint {
|
||||||
let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] {
|
let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] {
|
||||||
|
|
||||||
if installedLayoutConstraints.count > 0 {
|
if installedLayoutConstraints.count > 0 {
|
||||||
|
// remove the constraints from the UIView's storage
|
||||||
if let installedOnView = installInfo.view {
|
if #available(iOS 8, OSX 10.7, *) {
|
||||||
// remove the constraints from the UIView's storage
|
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
|
||||||
|
} else if let installedOnView = installInfo.view {
|
||||||
installedOnView.removeConstraints(installedLayoutConstraints)
|
installedOnView.removeConstraints(installedLayoutConstraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func equalTo(other: View) -> ConstraintDescriptionEditable
|
func equalTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func equalTo(other: Float) -> ConstraintDescriptionEditable
|
func equalTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func equalTo(other: Double) -> ConstraintDescriptionEditable
|
func equalTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
|
@ -110,7 +110,7 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
|
@ -125,7 +125,7 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
|
@ -230,7 +230,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .Equal)
|
return self.constrainTo(other, relation: .Equal)
|
||||||
}
|
}
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
internal func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
internal func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .Equal)
|
return self.constrainTo(other, relation: .Equal)
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
}
|
}
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
internal func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
internal func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
||||||
}
|
}
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
internal func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
internal func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@ -565,7 +565,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 9.0, *)
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
private func constrainTo(other: NSLayoutAnchor, relation: ConstraintRelation) -> ConstraintDescription {
|
private func constrainTo(other: NSLayoutAnchor, relation: ConstraintRelation) -> ConstraintDescription {
|
||||||
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue