参考链接:iPhone X,iPhone XS,iPhone XR,iPHone XS Max 适配
启动图尺寸 机型 命名
640 × 960 iPhone4s Default@2x
640 × 1136 iPhone5s Default-568h@2x
750 × 1334 iPhone Default-667h@2x
1242 × 2208 iPhonePlus Default-736h@3x
1125 × 2436 iPhoneX, XS Default-812h@3x
828 x 1792 iPhoneXR Default-828h@2x
1242 x 2688 iPhoneX Max Default-1242h@3x
以上是我们需要适配的手机机型,其中iphon4s我这已经不适配了
iphonex 系列导航栏和tabbar的高度发生了变化,就是“齐刘海”+底部触摸条
OC:
#define iphoneX ([[UIApplication sharedApplication] statusBarFrame].size.height>20?YES:NO)
#define kNavBarHeight (iphoneX ? 88.0 : 64.0)
#define KTabBarHeight iphoneX ? CGFloat(83.0) : CGFloat(49.0)
#define kBottomBarHeight (iphoneX ? 34.0 : 0)
#define kContentHeight (kScreenHeight - kNavBarHeight-kBottomBarHeight)
swift:
let KIphoneX = UIApplication.shared.statusBarFrame.size.height > 20 ? true : false
let KNavgationHeight = KIphoneX ? CGFloat(88.0) : CGFloat(64.0)
let KTabBarHeight = KIphoneX ? CGFloat(83.0) : CGFloat(49.0)
let kBottomBarHeight = KIphoneX ? CGFloat(34.0) : CGFloat(0)
let KHeightTime = kScreenHeight / 667
还有一种判断是否为iphonx的方法
#define iphoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size)||CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size)||CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size)) : NO)
根据手机的大小判断
网友评论