Last active
December 9, 2017 18:49
-
-
Save Mazyod/dcc263353fc11cc6a3026ffe7642005e to your computer and use it in GitHub Desktop.
SafeArea Top Constraint Setup, with Backwards Compatability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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