iOS iPhoneX适配

//状态栏高度
+ (CGFloat)navStatusBarHeight;
//标题栏高度
+ (CGFloat)navTitleBarHeight;
//状态栏 + 标题栏 高度
+ (CGFloat)statusBarAndNavTitleBarHeight;
//tabbar高度
+ (CGFloat)tabbarBarHeight;

//状态栏高度

  • (CGFloat)navStatusBarHeight
    {
    return [[UIApplication sharedApplication] statusBarFrame].size.height;

}
//标题栏高度

  • (CGFloat)navTitleBarHeight
    {
    UINavigationController *navController = //获取导航栏控制器
    if ([navController isKindOfClass:[UINavigationController class]]) {
    return navController.navigationBar.frame.size.height;
    }else
    {
    UINavigationBar *navBar = [UINavigationBar new];
    return navBar.frame.size.height;
    }
    }

//状态栏 + 标题栏 高度

  • (CGFloat)statusBarAndNavTitleBarHeight
    {
    return [self navStatusBarHeight] + [self navTitleBarHeight];
    }

//tabbar高度

  • (CGFloat)tabbarBarHeight
    {
    if (//判断tabbar控制器是否存在) {
    return //返回tabbarController.tabBar.frame.size.height;
    }else
    {
    UITabBar *tabbar = [[UITabBar alloc] init];
    return tabbar.frame.size.height;
    }
    }

你可能感兴趣的:(iOS iPhoneX适配)