iOS14 statusBarHeight is not 44.0 on some devices

Code Block
[UIApplication sharedApplication].statusBarFrame.size.height;

This code return 48 on iPhone 11, but 40 on iPhone 11 pro Max, and others return 44, but before iOS14, it will always return 44, is it a bug or a feature?

Here are what I saw with Xcode 12.1 GM

iPhone11: 48
iPhone12/12 pro/12 pro max: 47
iPhone12 mini: 44 but navigation bar starts with 50, this seems to be bug for Apple.
Other iPhones: 44.
The neweast Xcode Version 12.1 (12A7403) is same with

"Here are what I saw with Xcode 12.1 GM

iPhone11: 48
iPhone12/12 pro/12 pro max: 47
iPhone12 mini: 44 but navigation bar starts with 50, this seems to be bug for Apple.
Other iPhones: 44."


It is possible that this is Xcode's bug on iphone12mini simulator.
It's actually not a bug, but a misconception from us as developers. We've always used the status bar height as the distance between the navigation bar and the very top, however we should be using the safe area's top inset. Until iOS 12, the status bar height has always matched the safe area's top inset, but now they added some padding at the bottom in certain devices.

Code Block swift
let topInset: CGFloat = UIApplication.shared.keyWindow?.safeAreaInsets.top ?? UIApplication.shared.statusBarFrame.size.height


Has anyone got ahold of a physical iPhone 12 mini and been able to check that this bug (status bar 44pts but top safe area 50pts ) is a simulator only issue? It's still an issue in Xcode 12.2.
@joamafer, your point is valid but I think there is a bug here:

When I programmatically position a UIBarPositionTopAttached UIToolbar at the top of an iPhone 12 mini with the origin.y position set to the top of the safe area, the automatic extension of the bar's background color under the status bar is 6 pixels shy of reaching the top of the screen on the simulator.


On Xcode 12.4, the 12 mini emulator gives 2435, 44, 44, 1125 and 375 to the following lines of code:

    int screenHeight = (int)UIScreen.mainScreen.nativeBounds.size.height;

    int navBarHeight = (int)self.navigationController.navigationBar.bounds.size.height;

    int statusBarHeight = (int)[UIApplication sharedApplication].statusBarFrame.size.height;

    int screenWidth = (int)UIScreen.mainScreen.nativeBounds.size.width;

    int navBarWidth = (int)self.navigationController.navigationBar.bounds.size.width;

Connecting an iPhone 12 mini device and running the same code, the returns are 2340, 44, 50, 1080 and 375.
I connected an iPhone 12 Pro and the return values were the same for the emulator as for the device.

There is a bug... Thanks for the suggestion to connect a real device!
Thanks for updating the thread @tf1962!
iOS14 statusBarHeight is not 44.0 on some devices
 
 
Q