Skip to content

Instantly share code, notes, and snippets.

@StanislavK
Last active September 25, 2017 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StanislavK/0c41ba2899fb58a0518d8d5a7a22d16b to your computer and use it in GitHub Desktop.
Save StanislavK/0c41ba2899fb58a0518d8d5a7a22d16b to your computer and use it in GitHub Desktop.
public struct DeviceModel {
/// Returns true, if iPhoneX is detected
/// Detection is based on the portrait height, see https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
public static var isiPhoneX: Bool = {
let iPhoneXPortaitHeight: CGFloat = 812
let currentDevicePortraitHeight: CGFloat = UIScreen.main.fixedCoordinateSpace.bounds.size.height
return currentDevicePortraitHeight == iPhoneXPortaitHeight ? true : false
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment