Skip to content

Instantly share code, notes, and snippets.

@iamchiwon
Created August 27, 2018 09:41
Show Gist options
  • Save iamchiwon/efcce3ff6ff37d36296e10d89721d97e to your computer and use it in GitHub Desktop.
Save iamchiwon/efcce3ff6ff37d36296e10d89721d97e to your computer and use it in GitHub Desktop.
iPhoneX margins
let screenSize = UIScreen.main.bounds.size
let screenWidth = screenSize.width
let screenHeight = screenSize.height
let statusHeight: CGFloat = {
guard #available(iOS 11.0, *), let window = UIApplication.shared.keyWindow else {
return 0
}
return window.safeAreaInsets.top
}()
let bottomMargin: CGFloat = {
guard #available(iOS 11.0, *), let window = UIApplication.shared.keyWindow else {
return 0
}
return window.safeAreaInsets.bottom
}()
let thin1px: CGFloat = {
1 / UIScreen.main.nativeScale
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment