LoginSignup
0
0

More than 5 years have passed since last update.

iPhone Xs Max の判定

Posted at

iPhone Xs Max 辛い

最近出たiPhoneXsMaxがreactnativeで対応されていないところが多くて、
iPhoneXsMax用の判定できるようにした。
これを判定させたいところでimportするだけで大丈夫!(booleanで返ってくるから便利だと思う)

import { Platform, Dimensions } from 'react-native';

const XSMAX_WIDTH = 414;
const XSMAX_HEIGHT = 896;

// iPhone XS Max対応
export const _IPhoneXsMax = () => {
  const { width, height } = Dimensions.get('window');
  return (
    Platform.OS === 'ios' &&
    (width === XSMAX_WIDTH && height === XSMAX_HEIGHT)
  );
}

使用例

import {_IPhoneXsMax } from "path"

height: _IPhoneXsMax()
        ? 110
        : 92
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0