Created
February 21, 2019 14:11
-
-
Save KanshuYokoo/73b6d59e5ddc90242c2906d3426706bd to your computer and use it in GitHub Desktop.
ios react native iphonex
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
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