Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>[UIApplication sharedApplication].statusBarFrame.size.height</code>. But since all sizes are in points, not in pixels, status bar height always equals 20.</p> <p><strong>Update.</strong> Seeing this answer being considered helpful, I should elaborate.</p> <p>Status bar height is, indeed, equals 20.0f points <em>except</em> following cases:</p> <ul> <li>status bar has been hidden with <code>setStatusBarHidden:withAnimation:</code> method and its height equals 0.0f points;</li> <li>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.</li> </ul> <p>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 <em>will not</em>, 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).</p> <p><strong>Update 2.</strong> There's also a case of user interface orientation. Status bar does not respect the orientation value, thus status bar height value for <em>portrait</em> mode is <code>[UIApplication sharedApplication].statusBarFrame.size.height</code> (yes, default orientation is always portrait, no matter what your app info.plist says), for <em>landscape</em> - <code>[UIApplication sharedApplication].statusBarFrame.size.width</code>. To determine UI's current orientation when outside of <code>UIViewController</code> and <code>self.interfaceOrientation</code> is not available, use <code>[UIApplication sharedApplication].statusBarOrientation</code>.</p> <p><strong>Update for iOS7.</strong> 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 <code>UINavigationBar</code>'s <em>tiled</em> 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.</p> <p><img src="https://i.stack.imgur.com/clGaT.png" alt="Navigation bar tiled background is also tiled to status bar"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload