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?

Post marked as unsolved Up vote post of Asura19 Down vote post of Asura19
1.4k views

5 Replies

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.