mirror of https://github.com/SnapKit/SnapKit
Allow implied superview for equalTo(constant)
This commit is contained in:
parent
c1a3bda5a6
commit
7e8c173224
|
@ -87,11 +87,16 @@ public class Constraint {
|
||||||
|
|
||||||
// get layout to
|
// get layout to
|
||||||
#if os(iOS) || os(tvOS)
|
#if os(iOS) || os(tvOS)
|
||||||
let layoutTo: AnyObject? = self.to.view ?? self.to.layoutSupport
|
var layoutTo: AnyObject? = self.to.view ?? self.to.layoutSupport
|
||||||
#else
|
#else
|
||||||
let layoutTo: AnyObject? = self.to.view
|
var layoutTo: AnyObject? = self.to.view
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// use superview if possible
|
||||||
|
if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height {
|
||||||
|
layoutTo = layoutFrom.superview
|
||||||
|
}
|
||||||
|
|
||||||
// create layout constraint
|
// create layout constraint
|
||||||
let layoutConstraint = LayoutConstraint(
|
let layoutConstraint = LayoutConstraint(
|
||||||
item: layoutFrom,
|
item: layoutFrom,
|
||||||
|
@ -206,19 +211,3 @@ public class Constraint {
|
||||||
view.snp.remove(layoutConstraints: layoutConstraints)
|
view.snp.remove(layoutConstraints: layoutConstraints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//extension Constraint: Hashable {
|
|
||||||
//
|
|
||||||
// public var hashValue: Int {
|
|
||||||
// return self.layoutConstraints.hashValue
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//public func ==(lhs: Constraint, rhs: Constraint) -> Bool {
|
|
||||||
// return (lhs.from == rhs.from &&
|
|
||||||
// lhs.to == rhs.to &&
|
|
||||||
// lhs.relation == rhs.relation &&
|
|
||||||
// lhs.multiplier.constraintMultiplierTargetValue == rhs.multiplier.constraintMultiplierTargetValue &&
|
|
||||||
// lhs.priority.constraintPriorityTargetValue == rhs.priority.constraintPriorityTargetValue)
|
|
||||||
//}
|
|
||||||
|
|
Loading…
Reference in New Issue