Skip to content

Instantly share code, notes, and snippets.

@KanshuYokoo
Created February 21, 2019 14:11
Show Gist options
  • Save KanshuYokoo/73b6d59e5ddc90242c2906d3426706bd to your computer and use it in GitHub Desktop.
Save KanshuYokoo/73b6d59e5ddc90242c2906d3426706bd to your computer and use it in GitHub Desktop.
ios react native iphonex
import { Dimensions, Platform } from 'react-native';
export function isIphoneX() {
const dimWindow = Dimensions.get('window')
return (
Platform.OS === 'ios' &&
(isIPhoneXSize(dimWindow) || isIPhoneXRMAXSize(dimWindow))
)
}
export function isIPhoneXSize(window) {
return window.height === 812 || window.width === 812
}
// iPhoneXS, iPhoneXR, iPhoneXRMAX
export function isIPhoneXRMAXSize(window) {
return window.height === 896 || window.width === 896
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment