Skip to content

Instantly share code, notes, and snippets.

@KonstantinBerkow
Created February 23, 2018 13:01
Show Gist options
  • Save KonstantinBerkow/e6d015533945448aaa44081abcf529e2 to your computer and use it in GitHub Desktop.
Save KonstantinBerkow/e6d015533945448aaa44081abcf529e2 to your computer and use it in GitHub Desktop.
Main anchors template
let leadingAnchor: NSLayoutXAxisAnchor
let topAnchor: NSLayoutYAxisAnchor
let trailingAnchor: NSLayoutXAxisAnchor
let bottomAnchor: NSLayoutYAxisAnchor
let centerXAnchor: NSLayoutXAxisAnchor
let centerYAnchor: NSLayoutYAxisAnchor
if #available(iOS 11, *) {
let guide = rootView.safeAreaLayoutGuide
leadingAnchor = guide.leadingAnchor
topAnchor = guide.topAnchor
trailingAnchor = guide.trailingAnchor
bottomAnchor = guide.bottomAnchor
centerXAnchor = guide.centerXAnchor
centerYAnchor = guide.centerYAnchor
} else {
leadingAnchor = rootView.leadingAnchor
topAnchor = rootView.topAnchor
trailingAnchor = rootView.trailingAnchor
bottomAnchor = rootView.bottomAnchor
centerXAnchor = rootView.centerXAnchor
centerYAnchor = rootView.centerYAnchor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment