IPhone X Status Bar Height

I developed the application without autoLayoutor interface-builder, all by code. It works fine in everyone iPhonesexcept iPhone Xwhere the top panel remains under the new black thing in the middle.

Can I get this height by code, so can I push mine Navigationbarto this height down and everything works fine?

The solutions I see use automatic layout.

I just want to get the distance to move it down.

+4
source share
2 answers

In my Swift application, I get framestatus bars with

Swift: UIApplication.shared.statusBarFrame

Objective-C: [UIApplication sharedApplication].statusBarFrame

What a CGRect, so you can get its height by doing size.height. So you can do it in Objective-C:

[UIApplication sharedApplication].statusBarFrame.size.height
+10

, :

UIApplication.shared.keyWindow!.safeAreaInsets.top

UIApplication.shared.keyWindow!.safeAreaInsets.bottom

safeAreaLayoutGuide

+2

Source: https://habr.com/ru/post/1687572/


All Articles