[iOS功能]- 获取导航栏,状态栏,tabBar高度, toolBar高度

3,003 阅读1分钟
// 状态栏
CGFloat statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
// 导航栏
CGFloat navigationHeight = self.navigationController.navigationBar.frame.size.height;
//tabBar高度 在tabBarController中使用 继承自UITabBarController的VC
CGFloat tabBarHeight = self.tabBar.frame.size.height;
// 在非tabBarController中使用 (这儿取你当前tabBarVC的实例)
UITabBarController *tabBarVC = [[UITabBarController alloc] init];
CGFloat tabBarHeight = tabBarVC.tabBar.frame.size.height;
// toolBar高度
CGFloat toolBarHeight = self.navigationController.toolBar.frame.size.height;