mirror of https://github.com/SnapKit/SnapKit
add @available to ConstraintLayoutGuide extension (#357)
* add @available to ConstraintLayoutGuide extension * Modify #available
This commit is contained in:
parent
17ed35c412
commit
6312572419
|
@ -31,6 +31,7 @@
|
||||||
public protocol LayoutConstraintItem: class {
|
public protocol LayoutConstraintItem: class {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 9.0, *)
|
||||||
extension ConstraintLayoutGuide : LayoutConstraintItem {
|
extension ConstraintLayoutGuide : LayoutConstraintItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,26 +62,31 @@ class SnapKitTests: XCTestCase {
|
||||||
|
|
||||||
func testGuideMakeConstraints() {
|
func testGuideMakeConstraints() {
|
||||||
let v1 = View()
|
let v1 = View()
|
||||||
let g1 = UILayoutGuide()
|
if #available(iOS 9.0, *) {
|
||||||
|
let g1 = UILayoutGuide()
|
||||||
|
self.container.addSubview(v1)
|
||||||
|
self.container.addLayoutGuide(g1)
|
||||||
|
|
||||||
self.container.addSubview(v1)
|
v1.snp.makeConstraints { (make) -> Void in
|
||||||
self.container.addLayoutGuide(g1)
|
make.top.equalTo(g1.snp.top).offset(50)
|
||||||
|
make.left.equalTo(g1.snp.top).offset(50)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
v1.snp.makeConstraints { (make) -> Void in
|
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
|
||||||
make.top.equalTo(g1.snp.top).offset(50)
|
|
||||||
make.left.equalTo(g1.snp.top).offset(50)
|
g1.snp.makeConstraints { (make) -> Void in
|
||||||
return
|
make.edges.equalTo(v1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed")
|
||||||
|
|
||||||
|
} else {
|
||||||
|
XCTAssertTrue(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
|
}
|
||||||
|
|
||||||
g1.snp.makeConstraints { (make) -> Void in
|
|
||||||
make.edges.equalTo(v1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMakeImpliedSuperviewConstraints() {
|
func testMakeImpliedSuperviewConstraints() {
|
||||||
let v1 = View()
|
let v1 = View()
|
||||||
|
|
Loading…
Reference in New Issue