+ (CGFloat)statusBarHeight {
    if ( @available(iOS 13.0, *)) {
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowScene = [set anyObject];
        UIStatusBarManager *statusBarManager = windowScene.statusBarManager;
        CGFloat statusBarHeight = statusBarManager.statusBarFrame.size.height;
        if( @available(iOS 16.0, *)) {
            BOOL needAdjust = (statusBarHeight == 44);
            if(windowScene.windows.firstObject.safeAreaInsets.top == 59 && needAdjust) {
                statusBarHeight = 59;
            }
        }
        return statusBarHeight;
    }
    CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    CGFloat safeAreaTop = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.top;
    return MAX(statusBarHeight, safeAreaTop);
}
Answer from Pix1O on Stack Overflow
Top answer
1 of 16
516

[UIApplication sharedApplication].statusBarFrame.size.height. But since all sizes are in points, not in pixels, status bar height always equals 20.

Update. Seeing this answer being considered helpful, I should elaborate.

Status bar height is, indeed, equals 20.0f points except following cases:

  • status bar has been hidden with setStatusBarHidden:withAnimation: method and its height equals 0.0f points;
  • as @Anton here pointed out, during an incoming call outside of Phone application or during sound recording session status bar height equals 40.0f points.

There's also a case of status bar affecting the height of your view. Normally, the view's height equals screen dimension for given orientation minus status bar height. However, if you animate status bar (show or hide it) after the view was shown, status bar will change its frame, but the view will not, you'll have to manually resize the view after status bar animation (or during animation since status bar height sets to final value at the start of animation).

Update 2. There's also a case of user interface orientation. Status bar does not respect the orientation value, thus status bar height value for portrait mode is [UIApplication sharedApplication].statusBarFrame.size.height (yes, default orientation is always portrait, no matter what your app info.plist says), for landscape - [UIApplication sharedApplication].statusBarFrame.size.width. To determine UI's current orientation when outside of UIViewController and self.interfaceOrientation is not available, use [UIApplication sharedApplication].statusBarOrientation.

Update for iOS7. Even though status bar visual style changed, it's still there, its frame still behaves the same. The only interesting find about status bar I got – I share: your UINavigationBar's tiled background will also be tiled to status bar, so you can achieve some interesting design effects or just color your status bar. This, too, won't affect status bar height in any way.

2 of 16
104

Go with Martin's suggestion to the question: Get iPhone Status Bar Height.

CGFloat AACStatusBarHeight()
{
    CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
    return MIN(statusBarSize.width, statusBarSize.height);
}

And in Swift

func statusBarHeight() -> CGFloat {
    let statusBarSize = UIApplication.shared.statusBarFrame.size
    return Swift.min(statusBarSize.width, statusBarSize.height)
}

It seems like a hack, but it's actually pretty solid. Anyway, it's the only working solution.

Old Answer

The following code, which would go in your custom subclass of UIViewController, almost worked to support landscape. But, I noticed a corner case (when rotating from right > unsupported upside-down > left) for which it didn't work (switched height & width).

BOOL isPortrait = self.interfaceOrientation == UIInterfaceOrientationPortrait;
CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size;
CGFloat statusBarHeight = (isPortrait ? statusBarSize.height : statusBarSize.width);
🌐
Apple Community
discussions.apple.com › thread › 254236246
iOS 16 status bar height is getting wrong on iPhone 14 series
func getStatusBarHeight() -> CGFloat { var statusBarHeight: CGFloat = 0 if #available(iOS 13.0, *) { let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 } else { statusBarHeight = UIApplication.shared.statusBarFrame.height } return statusBarHeight } ... iOS18 extend wallpaper and status bar colour issue When turning on extend wallpaper iOS picks a solid colour to push before wallpaper starts.
🌐
Apple Developer
developer.apple.com › forums › thread › 662466
iOS14 statusBarHeight is not 44.0 … | Apple Developer Forums
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.
🌐
Apple Developer
developer.apple.com › forums › thread › 716231
iPhone14 Pro navigator originY str… | Apple Developer Forums
I use the (navigator bar height + status bar height) to calculate the originY of the content view. That assumes the navigation bar always abuts the status bar with no gap or overlap, but I don’t know if that relationship has ever actually been documented by Apple. If that happened to be true for past models, it seems not to be true for the iPhone 14 ...
Top answer
1 of 5
6

You should never hardcode the exact value of the height at any point in your code.

As long as you use default UI components (UINavigationController / UITableView / UICollectionView / etc.) you usually don't need to worry about the status bar height at all. These ViewControllers should layout correctly on any device and any orientation.

If you do have custom layout needs, you should refer to the safeAreaLayoutGuide on UIView, instead of hardcoding a height: https://developer.apple.com/documentation/uikit/uiview/2891102-safearealayoutguide?language=objc


But to make this answer complete - the size of the status bar is different on different devices and different orientations:

  • Most devices up to the iPhone X have a 20pt height in portrait & landscape.
    (20px, 40px, 60px in @1x, @2x, @3x)
  • On iPhone X in portrait it's 44pt (so 44px, 88px, 132px accordingly).
    In landscape the height is different though.
2 of 5
1

Your parent view controller will resize it's view to the right size. You can

  • make your view controller load a subclass of UIView and override -layoutSubviews
  • insert your subview with the proper starting size ([[ MyViewClass alloc ] initWithFrame:superview.bounds]) and the proper autoresizing mask. It's important when using autoresizing struts & springs that you give your view the proper size to start with.

BTW--another problem with hard coding the status bar height: it's sometimes double-height. (when the user is recording audio, making a phone call, using internet tethering, using navigation, etc.)

🌐
Apple Developer
developer.apple.com › forums › thread › 716257
Status bar height is getting wrong on iPhone 14 Pro ...
UIApplication.shared.statusBarFrame.height or let height = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 · Is not the right one. Indeed, it returns a height of 44.0 when a run my application from TestFlight (on debug mode no problem at all, this drives me nuts) while on these devices it should be 54.0 I do not understand why. Other people encounter this problem? Thank you ! ... See also this thread about similar weird behavior for iPhone 14 Pro models with TestFlight.
🌐
Medium
hacknicity.medium.com › how-ios-apps-adapt-to-the-various-iphone-14-screen-sizes-b2504a39b58f
How iOS Apps Adapt to the various iPhone 14 Screen Sizes | by Geoff Hackworth | Medium
September 24, 2022 - Since this is a new resolution, apps must be built with Xcode 14 or later to see it. The status bar is 7 points taller than the iPhone 14 Plus to account for the Dynamic Island. The total navigation bar height (including the status bar) is only ...
🌐
Reddit
reddit.com › r/jailbreak › [question] how to get the status bar to be the same size everywhere on ios 14? the flex patch and usual tweaks (eg samestatusbar) don’t work.
r/jailbreak on Reddit: [Question] How to get the status bar to be the same size everywhere on iOS 14? The Flex patch and usual tweaks (eg SameStatusBar) don’t work.
February 12, 2021 - Thanks for this, I’ve had that tweak installed since I updated to iOS 14 and never knew about that toggle. Thanks for your tweaks too, very useful and quickly updated :) More replies ... Looked for one all through iOS 13. Nothing has popped up so far ... Repost from this thread back when iOS 13 released. I haven't been able to find a solution aside from Little11, but the trade off is using your notched phone as iPhoneX on legacy (ie control control center interaciton changes, etc).
Find elsewhere
🌐
GitHub
github.com › apache › cordova-plugin-statusbar › issues › 243
iPhone 14 Pro floating island status bar height incorrect · Issue #243 · apache/cordova-plugin-statusbar
August 16, 2022 - Bug Report Problem iPhone 14 pro has a new status bar with the floating island. Instead of the safe inset being 47 points like with the notch based iPhones, it is now 59 points. See this detailed blog post about the new safe are with the...
Published   Sep 23, 2022
🌐
Apple Developer
developer.apple.com › forums › thread › 715417
Space under status bar(dynamic island) in iPhone 14 Pros
If you look closely at UseYourLoaf's diagram for the iPhone 14 Pro Safe Area... There's a 54-point height at the top, with an additional 5-point height below it.
🌐
Apple Community
discussions.apple.com › thread › 254772213
How do I Enlarge iphone status bar magnif… - Apple Community
You can activate the function here: Settings → Accessibility → Display & Text Size → Larger Text → enable Larger Accessibility Sizes and set the scroller at the bottom to one of the 5 highest "notches". After that you should be able to enlarge icons, time and battery in the status bar.
🌐
Apple Developer
developer.apple.com › design › human-interface-guidelines › status-bars
Status bars | Apple Developer Documentation
A status bar appears along the upper edge of the screen and displays information about the device’s current state, like the time, cellular carrier, and battery level.
🌐
Use Your Loaf
useyourloaf.com › blog › iphone-14-screen-sizes
iPhone 14 Screen Sizes
September 18, 2023 - The iPhone 14 Pro screen is 3 points (9 pixels) wider and 8 points (24 pixels) taller than the similar sized iPhone 13 Pro. The status bar also increases from 47 to 54 points high, but note that the top safe area inset is 59 points. This reduces ...
🌐
Reddit
reddit.com › r/reactnative › how to use the status bar height instead of the safe area top inset on ios?
r/reactnative on Reddit: How to use the Status Bar height instead of the Safe Area top inset on iOS?
September 24, 2025 -

Just wondering if I can use the Status Bar height from different iPhones (which tends to be around 52–54px) instead of the top inset provided by SafeAreaView (which tends to be around 60–62px).

For context, see the image attached above. I’m willing to design my project within the 54 points related to the Status Bar on this iPhone 16 Pro, but I don’t want to hardcode it since different iPhones have different sizes.

I know this sounds like it’s not important for the end result (which is true), but I come from a design background and I’m trying to get a pixel-perfect layout compared to what I usually design in Figma. I couldn’t find anything on this here or anywhere else.

What I’ve discovered is that native apps like Airbnb seem to use the Status Bar instead of the Safe Area, which is one of the reasons I want to perfect this approach.

Thanks in advance!

🌐
Figma
figma.com › community › file › 831970552583056395 › ios-status-bar
iOS Status Bar | Figma
Contains status bars for both iPhone with and without notch and iPadsMade into component with lots of different variants. Like call toggle, WiFi, notch and different themes.The components are very easy to customize, clean, clearly labeled, and ready to be copied over to your projects.
Top answer
1 of 3
30

If you're using Expo you can use Constants.statusBarHeight.

import Constants from 'expo-constants';
const statusBarHeight = Constants.statusBarHeight;

If you're using Vanilla React Native with React Navigation you can use the following:

import { useSafeAreaInsets } from 'react-native-safe-area-context';
const insets = useSafeAreaInsets();
const statusBarHeight = insets.top;

See: https://reactnavigation.org/docs/handling-safe-area/#use-the-hook-for-more-control

Sample Code:

import * as React from 'react';
import { Text, View, StatusBar } from 'react-native';
import Constants from 'expo-constants';
import { useSafeAreaInsets, SafeAreaProvider } from 'react-native-safe-area-context';

export default function App() {
  return (
    <SafeAreaProvider>
      <ChildScreen />
    </SafeAreaProvider>
  );
}

function ChildScreen() {
  const insets = useSafeAreaInsets();
  
  return (
    <View style={{ flex: 1, justifyContent: 'center'}}>
      <Text>
        {insets.top}
      </Text>
      <Text>
        {Constants.statusBarHeight}
      </Text>
      <Text>
        {StatusBar.currentHeight ?? 'N/A'}
      </Text>
    </View>
  );
}

Output:

Samsung Galaxy S10 5G iPhone 8 Plus iPhone 11 Pro Max Web
insets.top 39.71428680419922 20 44 0
Constants.statusBarHeight 39 20 44 0
StatusBar.currentHeight ?? 'N/A' 39.42856979370117 N/A N/A N/A

Live code: https://snack.expo.dev/@dcangulo/statusbarheight

2 of 3
4

You can use React Navigation that already have support of iPhone X.

Even if you don't want use this library because of some reason - you still can read source code to copy implementation in your code

🌐
Stack Overflow
stackoverflow.com › questions › 27815153 › status-bar-height-increase-in-iphone
ios - Status bar height increase in iphone - Stack Overflow
Status bar height is, indeed, equals 20.0f points except following cases: status bar has been hidden with setStatusBarHidden:withAnimation: method and its height equals 0.0f points; as @Anton here pointed out, during an incoming call outside ...
🌐
Meteor
forums.meteor.com › mobile
Gap Between Status Bar and App (iPhone 14) - mobile - Meteor Forum
February 11, 2023 - Hi guys, On the iPhone 14, I am seeing a small gap between the status bar and my app. Has anyone seen this issue? Been trying to debug this but I’m stumped. Thanks