First, in the old version of iOS, the status bar is always white style. In iOS 7, we can modify the appearance of the status bar in each view controller. The Uistatusbarstyle constant allows you to specify that the contents of the status bar are dark or bright colors. By default, the status bar displays a dark color. That is, the time on the status bar, the battery indicator, and the Wi-Fi signal are displayed as dark colors. If a dark color is used as the background in the navigation bar, the effect looks as follows:
In this case, we might want to change the style of the navigation bar to bright colors. There are two ways to do this. In iOS 7, we can overriding methods in each view controller preferredStatusBarStyle: , as follows:
-(Uistatusbarstyle) Preferredstatusbarstyle { return uistatusbarstylelightcontent;}
PS: This method is only called if the following code is set ( for Preferredstatusbarstyle does not perform a problem ):
[Self.navigationController.navigationBar Setbarstyle:uibarstyleblack];
The effect of the above code is as follows:
Second, in iOS 7, the above method to modify the status bar style is very good. In addition, we can use UIApplication's Statusbarstyle method to set the status bar, but first you need to stop using it View controller-based status bar appearance . In the Info tab of Project target, insert a new key with the name View controller-based status bar appearance , and set its value to No.
You can then use the following code to set the status bar style:
[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];
IOS Modify status bar Preferredstatusbarstyle do not perform a problem