iOS 8、iOS 9、iOS 10 和 iOS 11 上的 UITabBar 的高度是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25550831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:05:45  来源:igfitidea点击:

What's the height of a UITabBar on iOS 8, iOS 9, iOS 10, and iOS 11?

ioscocoa-touchios8uitabbarios9

提问by Johannes Fahrenkrug

The height of the UITabBar seems to have changed between iOS 7 and 8/9/10/11. I'm posting this question for others to easily find the answer.

UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题供其他人轻松找到答案。

So: What's the height of a UITabBar on iOS 8/9/10/11 on iPhone and iPad?

那么:iPhone 和 iPad 上 iOS 8/9/10/11 上的 UITabBar 的高度是多少?

回答by Johannes Fahrenkrug

For iOS 8, 9, and 10 the height is 49 points, both on iPad and iPhone and both in portrait and landscape. It used to be 56 points on iOS 7.

对于 iOS 8、9 和 10,高度为49 磅,无论是在 iPad 和 iPhone 上,还是在纵向和横向模式下。在 iOS 7 上曾经是 56 分。

For iOS 11, things get a bit more complicated:

对于 iOS 11,事情变得有点复杂:

In portraitand regular landscape, the height is still 49 points. In compact landscape, the height is now 32 points.

人像常规风景中,高度仍为49 点。在紧凑的景观中,高度现在是32 点

On iPhone X, the height is 83 pointsin portrait and 53 pointsin landscape.

在 iPhone X 上,纵向高度为83磅,横向高度为53磅。

回答by Adrien

iOS 9 and iOS 10 still uses 49 points for the Tab Bar (and 64 points for a navigation bar) Thanks for the self Q/A, was actually helpful to conform what I had on storyboard.

iOS 9 和 iOS 10 仍然使用标签栏 49 分(导航栏 64 分)感谢自我问答,实际上有助于符合我在故事板上的内容。

回答by Matti-Koopa

I would recommend just calculating it using TabBar.Height - UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom. Check for system version >= 11 first.

我建议只使用TabBar.Height - UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom. 首先检查系统版本 >= 11。