美文网首页
iOS开发<iPhoneX系列手机适配>

iOS开发<iPhoneX系列手机适配>

作者: farmerly | 来源:发表于2018-09-29 14:40 被阅读468次

    iPhoneX-iPhoneXS-iPhoneXR-iPhoneXMAX手机型号适配

    #ifndef FMConfig_h
    #define FMConfig_h
     
    //判断设备类型
    #define iPhone4 ([UIScreen mainScreen].bounds.size.height == 480)
    #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
    #define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size)) : NO)
    #define iPhone6plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size)) : NO)
    // 判断是否是iPhone X
    #define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
    // 判断是否是iPhone XR
    #define iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
    // 判断是否是iPhone XS
    #define iPhoneXS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
    // 判断是否是iPhone X Max
    #define iPhoneXMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
    //iPhoneX系列
    #define NavgationHeight 44.0f
    #define STATUS_BAR_HEIGHT ((iPhoneX==YES || iPhoneXR ==YES || iPhoneXS== YES || iPhoneXMax== YES) ? 44.0 : 20.0)
    #define NAVGATION_BAR_HEIGHT ((iPhoneX==YES || iPhoneXR ==YES || iPhoneXS== YES || iPhoneXMax== YES) ? 88.0 : 64.0)
    #define TAB_BAR_HEIGHT ((iPhoneX==YES || iPhoneXR ==YES || iPhoneXS== YES || iPhoneXMax== YES) ? 83.0 : 49.0)
    
    #endif
    

    相关文章

      网友评论

          本文标题:iOS开发<iPhoneX系列手机适配>

          本文链接:https://www.haomeiwen.com/subject/uyavoftx.html