/**
获取 状态栏高度
@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;
}
}
网友评论