首页 > 代码库 > Status Bar in iOS7

Status Bar in iOS7

This is a very important change in iOS 7: the status bar is no longer a separate bar. It’s now something that simply gets drawn on top of your view controllers. In previous versions of iOS, if your app displayed the status bar the height of the view controller’s view was reduced to compensate — especially if it contained a navigation bar. In iOS 7, your view controllers are always supposed to fill the entire screen.

If your app has content near the top of the screen but no navigation bar, then you have a problem on your hands, as the status bar will draw on top of that content. That’s exactly what’s happening on the Map Detail screen. There are three possible ways to handle this:

• Move your content down by 20 points and make room for the status bar. This is the easiest solution, but it doesn’t work very well if your content is embedded in a scroll view or relies on a table view.

• Implement the prefersStatusBarHidden method in your UIViewController subclass, and return YES to hide the status bar. The problem with this approach is that a user wants to keep the status bar visible in most non-game apps. 

• Add a navigation bar on top, either by embedding the view controller inside a navigation controller, or by adding your own instance of UINavigationBar. The navigation bar will extend under the status bar. Your content will still sit under these two bars, but the navigation bar will blur it. This is the approach you’ll take in this tutorial. 

 

 

--------iOS_7_by_Tutorials_1_1/Chapter 7: Transitioning to iOS 7 – What’s New with Auto Layout  Page.244

Status Bar in iOS7