适配X

作者: 又又轻 | 来源:发表于2018-02-25 09:59 被阅读14次

    /**

     获取 状态栏高度

     @return getStatusBarHeight

     */

    + (CGFloat)getStatusBarHeight{

        return [[UIApplication sharedApplication]statusBarFrame].size.height;

    }

    - (UIViewController*)currentViewController

    {

        UIWindow*keyWindow  = [UIApplicationsharedApplication].keyWindow;

        UIViewController*vc = keyWindow.rootViewController;

        while (vc.presentedViewController)

        {

            vc = vc.presentedViewController;

            if ([vc isKindOfClass:[UINavigationController class]])

            {

                vc = [(UINavigationController*)vcvisibleViewController];

            }

            elseif([vcisKindOfClass:[UITabBarControllerclass]])

            {

                vc = [(UITabBarController*)vcselectedViewController];

            }

        }

        returnvc;

    }

    - (UINavigationController*)currentNavigationController

    {

        return [self currentViewController].navigationController;

    }

    /**

     获取标题栏高度

     @return navTitleBarHeight

     */

    + (CGFloat)navTitleBarHeight{

        UINavigationController *nav = ;//获取导航栏控制器[]

        if ([nav isKindOfClass:[UINavigationController class]]) {

            return nav.navigationBar.frame.size.height;

        }else

        {

            UINavigationBar *navBar = [[UINavigationBar alloc]init];

            returnnavBar.frame.size.height;

        }

    }

    /**

     状态栏+标题栏  高度

     @return getStatusBarAndNavTitleBarHeight

     */

    + (CGFloat)getStatusBarAndNavTitleBarHeight

    {

        return [self getStatusBarHeight] + [self navTitleBarHeight];

    }

    //tabbar高度

    + (CGFloat)tabbarBarHeight

    {

        if (//判断tabbar控制器是否存在)

        {

            return //返回tabbarController.tabBar.frame.size.height;

        }

        else

        {

            UITabBar *tabbar = [[UITabBar alloc] init];

            returntabbar.frame.size.height;

        }

    }

    相关文章

      网友评论

          本文标题:适配X

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