React native 如何检查iPhone Xs Max?

React native 如何检查iPhone Xs Max?,react-native,React Native,我试图在react native中为iphonexsmax做一个具体的说明 这就是我从中获得的有关IphoneX的 iPhone Xs Max的维度是什么?仅仅添加iPhone Xs Max的维度就足够了吗?最后我说到: export function isIphoneXorAbove() { const dimen = Dimensions.get('window'); return ( Platform.OS === 'ios' && !Platfor

我试图在
react native
中为
iphonexsmax
做一个具体的说明

这就是我从中获得的有关IphoneX的


iPhone Xs Max的维度是什么?仅仅添加
iPhone Xs Max的维度就足够了吗?

最后我说到:

export function isIphoneXorAbove() {
  const dimen = Dimensions.get('window');
  return (
    Platform.OS === 'ios' &&
    !Platform.isPad &&
    !Platform.isTVOS &&
    ((dimen.height === 812 || dimen.width === 812) || (dimen.height === 896 || dimen.width === 896))
  );
}
但所有的功劳都归于此

编辑: 如果您希望此功能与iPhone 11和iPhone 12版本配合使用,您可以使用此功能:

function isIphoneWithNotch() {
  const dimen = Dimensions.get('window');
  return (
    Platform.OS === 'ios' &&
    !Platform.isPad &&
    !Platform.isTVOS &&
    (dimen.height === 780 ||
      dimen.width === 780 ||
      dimen.height === 812 ||
      dimen.width === 812 ||
      dimen.height === 844 ||
      dimen.width === 844 ||
      dimen.height === 896 ||
      dimen.width === 896 ||
      dimen.height === 926 ||
      dimen.width === 926)
  );
}

您可以使用
https://github.com/ptelad/react-native-iphone-x-helper
软件包。它允许您为
iphonex,XS,XS Max&XR

设计您的react原生应用程序,那么iphone11和12呢
function isIphoneWithNotch() {
  const dimen = Dimensions.get('window');
  return (
    Platform.OS === 'ios' &&
    !Platform.isPad &&
    !Platform.isTVOS &&
    (dimen.height === 780 ||
      dimen.width === 780 ||
      dimen.height === 812 ||
      dimen.width === 812 ||
      dimen.height === 844 ||
      dimen.width === 844 ||
      dimen.height === 896 ||
      dimen.width === 896 ||
      dimen.height === 926 ||
      dimen.width === 926)
  );
}