Skip to content

Instantly share code, notes, and snippets.

@Mazyod
Last active December 9, 2017 18:49
Show Gist options
  • Save Mazyod/dcc263353fc11cc6a3026ffe7642005e to your computer and use it in GitHub Desktop.
Save Mazyod/dcc263353fc11cc6a3026ffe7642005e to your computer and use it in GitHub Desktop.
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