Last active
November 2, 2017 11:03
-
-
Save PtitChevreuil/4f4da5f97dd506225fd0de39c94f0c37 to your computer and use it in GitHub Desktop.
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
// in your UIViewController | |
func setupMySubview() { | |
let topInset = compatibleSafeInsets.top | |
let bottomInset = compatibleSafeInsets.bottom | |
let leftInset = compatibleSafeInsets.left | |
let rightInset = compatibleSafeInsets.right | |
let height = view.frame.size.height - bottomInset - topInset | |
let width = view.frame.size.width - leftInset - rightInset | |
mySubview.frame = CGRect(x: leftInset, y: topInset, width: width, height: height) | |
} | |
// This is called on both iOS 11 and 10 | |
override func viewDidLayoutSubviews() { | |
setupMySubview() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment