美文网首页iOS 学习
iOS屏幕顶部、底部的高度)

iOS屏幕顶部、底部的高度)

作者: 零粹 | 来源:发表于2019-01-17 11:14 被阅读0次

判断是否是iPad

#define ISIPAD [[UIDevice currentDevice] userInterfaceIdiom] ==UIUserInterfaceIdiomPad

判断手机型号为X

#define is_IPHONEX [[UIScreen mainScreen] bounds].size.width == 375.0f &&([[UIScreen mainScreen] bounds].size.height == 812.0f)

获取状态栏的高度 iPhone X - 44pt 其他20pt

#define StatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height

获取导航栏的高度 - (不包含状态栏高度) 44pt

#define NavigationBarHeight self.navigationController.navigationBar.frame.size.height

屏幕底部 tabBar高度49pt + 安全视图高度34pt(iPhone X)

#define TabbarHeight self.tabBarController.tabBar.frame.size.height

屏幕顶部 导航栏高度(包含状态栏高度)

#define NavigationHeight (StatusBarHeight + NavigationBarHeight)

屏幕底部安全视图高度 - 适配iPhone X底部

#define TOOLH (is_IPHONEX ? 34 : 0)

屏幕底部 toolbar高度 + 安全视图高度34pt

#define ToolbarHeight self.navigationController.toolbar.frame.size.height

相关文章

网友评论

    本文标题:iOS屏幕顶部、底部的高度)

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