Add ConstraintMaker shortcuts for superview access (#341)

Added two new shortcuts for access superview in ConstraintMakerRelatable
`greaterThanOrEqualToSuperview`
`lessThanOrEqualToSuperview`
This commit is contained in:
Txai Wieser 2016-09-30 01:57:23 -03:00 committed by Robert Payne
parent da4426cb9a
commit 180ff1477e
1 changed files with 15 additions and 0 deletions

View File

@ -87,9 +87,24 @@ public class ConstraintMakerRelatable {
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
}
@discardableResult
public func lessThanOrEqualToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
guard let other = self.description.view.superview else {
fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.")
}
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
}
@discardableResult
public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
}
@discardableResult
public func greaterThanOrEqualToSuperview(_ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
guard let other = self.description.view.superview else {
fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.")
}
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
}
}