| Info | Value |
| --- | --- |
| Platform | ios |
| Platform Version | 8.0 |
| SnapKit Version | 3.0.1 |
| Integration Method | cocoapods/ |
In v0.21.0 it was possible to make constraints by pinning them to the bottom of the topLayoutGuide like this:
view.snp_makeConstraints { make in
make.top.equalTo(viewController.topLayoutGuideBottom)
}
This has been removed in fc298ae and replaced with UILayoutGuide but there is no replacement for iOS8 since topLayoutGuide is only available in iOS9+:
view.snp_makeConstraints { make in
make.top.equalTo(topLayoutGuide.snp.bottom)
}
@tomquist Ack, sorry I've left out the UIViewController
DSL from the 3.0.0 release. I'll try and get this added back in by end of next week.
@robertjpayne that would be great. I use those all the time
@robertjpayne if you want to give a couple of first steps, I'm sure we could get a PR going.
@sahandnayebaziz you can look at ConstraintViewDSL
and ConstraintLayoutGuideDSL
you're basically going to want to implement a ConstraintViewControllerDSL
.
Please make sure it's only available on iOS/tvOS though.
Hi @tomquist
Are you sure that topLayoutGuide
is only available in iOs 9+
the documentation says iOS 7.0+
.
Reference:
topLayoutGuide
bottomLayoutGuide
Yea actually @tomquist did you actually try this? I was just going to implement this but I believe it's unecessary.
You should be able to do:
self.container.snp.makeConstraints { (make) -> Void in
make.top.equalTo(vc.topLayoutGuide.snp.bottom)
make.bottom.equalTo(vc.bottomLayoutGuide.snp.top)
}
In iOS 8+ via SnapKit. The name is confusing it's actually UILayoutSupport rather than a UILayoutGuide.
Closing this as I believe it's no longer an issue and resolved by above comment ^^
Did't work for me, when I use navigationController. It's start from screen top, and my code
func loadWebView() -> Void {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view.addSubview(webView)
webView.snp.makeConstraints { (maker) in
maker.left.right.equalTo(view)
maker.top.equalTo(topLayoutGuide.snp.top)
maker.height.equalTo(300)
}
let myURL = URL(string: "http://bbs.iosre.com/")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
and show me
@jacinzhang maker.top.equalTo(topLayoutGuide.snp.top)
should probably be maker.top.equalTo(topLayoutGuide.snp.bottom)
?
@robertjpayne thanks, I'm careless.
Most helpful comment
Yea actually @tomquist did you actually try this? I was just going to implement this but I believe it's unecessary.
You should be able to do:
In iOS 8+ via SnapKit. The name is confusing it's actually UILayoutSupport rather than a UILayoutGuide.