/**
* 判断设备是否是iPhoneX
*/
export const isIphoneX = function isIphoneX() {
const iPhone = /iphone/gi.test(window.navigator.userAgent);
if (
iPhone &&
window.devicePixelRatio &&
window.devicePixelRatio === 3 &&
window.screen.width === 375 &&
window.screen.height === 812
) {
// iPhone X、iPhone XS
return true;
}
if (
iPhone &&
window.devicePixelRatio &&
window.devicePixelRatio === 3 &&
window.screen.width === 414 &&
window.screen.height === 896
) {
// iPhone XS Max
return true;
}
if (
iPhone &&
window.devicePixelRatio &&
window.devicePixelRatio === 2 &&
window.screen.width === 414 &&
window.screen.height === 896
) {
// iPhone XR
return true;
}
if (iPhone && window.screen.width === 390 && window.screen.height === 844) {
// iPhone 12/ iPhone 12 Pro
return true;
}
if (iPhone && window.screen.width === 428 && window.screen.height === 926) {
// iPhone 12 Pro Max
return true;
}
return false;
};