Allow implied superview for equalTo(constant)

This commit is contained in:
Robert Payne 2016-08-16 23:24:14 +12:00
parent c1a3bda5a6
commit 7e8c173224
1 changed files with 7 additions and 18 deletions

View File

@ -87,11 +87,16 @@ public class Constraint {
// get layout to
#if os(iOS) || os(tvOS)
let layoutTo: AnyObject? = self.to.view ?? self.to.layoutSupport
var layoutTo: AnyObject? = self.to.view ?? self.to.layoutSupport
#else
let layoutTo: AnyObject? = self.to.view
var layoutTo: AnyObject? = self.to.view
#endif
// use superview if possible
if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height {
layoutTo = layoutFrom.superview
}
// create layout constraint
let layoutConstraint = LayoutConstraint(
item: layoutFrom,
@ -206,19 +211,3 @@ public class Constraint {
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)
//}