Hiding the status bar conditionally for iPhone X

I asked about this on the Apple developer forums, but thought I’d try here as well.

The HIG for iPhone X recommends not hiding the status bar on iPhone X even if your app typically does hide the status bar, so I’m looking for a way to programmatically determine that it’s appropriate to leave the status bar visible (which would apply to iPhone X and presumably any future devices with similar characteristics).

I’ve seen a couple solutions online, one based on querying the phone model, and one based on checking to see if the top safe area inset is non-zero. These seem somewhat ad hoc though, and each seems to have potential weaknesses (for example, checking safeAreaInsets.top won’t work if the app is launched in landscape orientation).

It seems like since this is an HIG recommendation, there might be an ‘official’ way to go about intelligently determining at runtime whether or not to hide the status bar, but I haven’t seen anything like that. Does anyone have any suggestions?

This topic was automatically closed after 166 days. New replies are no longer allowed.