react-native 判断是不是IPhone X

import {  
    Platform,  
    Dimensions  
} from 'react-native';  
  
// iPhoneX  
const X_WIDTH = 375;  
const X_HEIGHT = 812;  
  
// screen  
const SCREEN_WIDTH = Dimensions.get('window').width;  
const SCREEN_HEIGHT = Dimensions.get('window').height;  
  
export default function isIphoneX() {  
    return (  
        Platform.OS === 'ios' &&   
        ((SCREEN_HEIGHT === X_HEIGHT && SCREEN_WIDTH === X_WIDTH) ||   
        (SCREEN_HEIGHT === X_WIDTH && SCREEN_WIDTH === X_HEIGHT))  
    )  
}  

  

posted @ 2018-10-30 11:51  年少的你如此美丽  阅读(930)  评论(0编辑  收藏  举报