2019-10-09
技术小刊
00

目录

Js判断iPhone XS、iPhone XS Max、iPhone XR适配
iPhone X、iPhone XS
iPhone XS Max
iPhone XR

探索关于手机适配的问题

Js判断iPhone XS、iPhone XS Max、iPhone XR适配

iPhone X、iPhone XS

js
var isIPhoneX = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812;

iPhone XS Max

js
var isIPhoneXSMax = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 896;

iPhone XR

js
var isIPhoneXR = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 414 && window.screen.height === 896;

依旧不用安全区域代码,如果要做刘海头 if (isIPhoneX || isIPhoneXSMax || isIPhoneXR) 垫高44px。 区分关键点:

1.是否需要考虑横屏情况 2.内补以及顶部固定显示需要动态控制显示
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:seek

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!