mirror of https://github.com/SnapKit/SnapKit
Add ConstraintMaker shortcuts for superview access (#341)
Added two new shortcuts for access superview in ConstraintMakerRelatable `greaterThanOrEqualToSuperview` `lessThanOrEqualToSuperview`
This commit is contained in:
parent
da4426cb9a
commit
180ff1477e
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue