iPhone X状态栏高度 [英] iPhone X status bar height
问题描述
我已经开发了一个没有 autoLayout
或 interface-builder
的应用程序,全部通过代码实现.除 iPhone X
以外,所有 iPhone
都可以正常运行,其中
I have developed an app without autoLayout
or interface-builder
, all by code. It runs ok in all iPhones
except iPhone X
where the top bar stays under the new black thing in the middle.
可以通过代码获取该高度,所以我可以将我的 Navigationbar
降低该高度,并且一切运行正常?
It's possible to get that height by code, so I can shift my Navigationbar
that height down and all runs normal ?
我看到的解决方案是自动布局.
The solutions I see, they use auto layout.
我只希望得到距离将其向下移动.
I just want the get the distance to shift it down..
推荐答案
在我的Swift应用程序中,我使用
In my Swift app, I get the frame
of the status bar with
Swift: UIApplication.shared.statusBarFrame
Objective-C: [UIApplication sharedApplication] .statusBarFrame
Objective-C: [UIApplication sharedApplication].statusBarFrame
这是一个 CGRect
,因此您可以通过对其进行 size.height
来获取其高度.因此,总而言之,您可以在Objective-C中执行此操作:
That's a CGRect
, so you can get its height by doing size.height
on that. So, altogether, you can do this in Objective-C:
[UIApplication sharedApplication].statusBarFrame.size.height
这篇关于iPhone X状态栏高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!