Technical Solutions for Hiding Status Bar in iOS 7

Dec 07, 2025 · Programming · 11 views · 7.8

Keywords: iOS7 | status bar | Objective-C

Abstract: This article discusses the common issue of hiding the status bar in iOS 7 and its solutions. It focuses on the method of modifying the Info.plist file for global status bar hiding, supplemented by view controller-based alternatives. The article explains the implementation steps, advantages, disadvantages, and considerations for both methods, helping developers quickly adapt to iOS 7's new features.

Problem Background

With the release of iOS 7, Apple made significant changes to status bar management, introducing view controller-based status bar appearance control. This caused many developers to find that previously working code to hide the status bar no longer functions after upgrading to iOS 7. For example, when using [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; or [UIApplication sharedApplication].statusBarHidden = YES;, the status bar may remain visible.

Core Solution: Modifying the Info.plist File

Based on the best answer, to globally hide the status bar in iOS 7, it can be achieved by modifying the application's Info.plist file. The specific steps are as follows:

  1. Open the Info.plist file of the project in Xcode.
  2. Add a new key-value pair with the key View controller-based status bar appearance and the value NO.

Setting this key to NO allows the application to use the traditional UIApplication-based status bar hiding methods. Thus, the previously mentioned code should work correctly.

However, it is important to note that if the application uses UIImagePickerController, this method may fail because UIImagePickerController could override this setting.

Alternative Method: Using View Controller-Based Approach

Another method leverages the view controller-based status bar management introduced in iOS 7. In each view controller where the status bar needs to be hidden, implement the prefersStatusBarHidden method. For example:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

This method allows finer control but requires individual setup for each view controller.

Comparison and Selection

Both methods have their pros and cons. Modifying the Info.plist file provides a global setting that is simple and efficient, but it may be limited by specific controllers like UIImagePickerController. The view controller-based method offers flexibility, suitable for scenarios requiring dynamic control of the status bar. Developers should choose the appropriate method based on application needs.

Conclusion

Hiding the status bar in iOS 7 requires adaptation to the new framework mechanisms. By modifying the Info.plist file or implementing the prefersStatusBarHidden method, the issue of the status bar not hiding can be effectively resolved. It is recommended to test different scenarios during development to ensure compatibility.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.