Is enabling Safe Area Layout Guides compatible to iOS below 11?
Swift 5
I just do this. It is simple and very close to the real thing (just added an 'r').
extension UIView {
var saferAreaLayoutGuide: UILayoutGuide {
get {
if #available(iOS 11.0, *) {
return self.safeAreaLayoutGuide
} else {
return self.layoutMarginsGuide
}
}
}
}
Use like this:
button.topAnchor.constraint(equalTo: view.saferAreaLayoutGuide.topAnchor, constant: 16)