Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SafeArea Top Constraint Setup, with Backwards Compatability
/** Safe area for status bar dodging only. If you use NavigationBars, this won't help.
*/
let topConstraint: NSLayoutConstraint
if #available(iOS 11.0, *) {
topConstraint = headerContainerView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor)
} else {
let statusBarHeight = UIApplication.shared.statusBarFrame.height
topConstraint = headerContainerView.topAnchor.constraint(equalTo: topAnchor, constant: statusBarHeight)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.