Created
March 8, 2019 12:03
-
-
Save ranmyfriend/a081dae969a7b39fd9feb0578962af7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension UIView { | |
var leftAnchor: NSLayoutXAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.leftAnchor : self.leftAnchor | |
} | |
var rightAnchor: NSLayoutXAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.rightAnchor : self.rightAnchor | |
} | |
var topAnchor: NSLayoutYAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.topAnchor : self.topAnchor | |
} | |
var bottomAnchor: NSLayoutYAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.bottomAnchor : self.bottomAnchor | |
} | |
private var iOS11NAbove: Bool { | |
if #available(iOS 11.0, *) { | |
return true | |
} | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment